-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: how to build a package without "cruft"? #80
Comments
I think the way to structure application builds is not to eliminate the "cruft" but to hide it in another wrapper layer. Conceptually like: let
venv = pythonSet.mkVirtualEnv "hello-world-env" workspace.deps.default;
in
pkgs.runCommand "hello-world" { } ''
mkdir -p $out/bin
ln -s ${venv}/bin/hello $out/bin
'' There should be a utility function to do that: let
venv = pythonSet.mkVirtualEnv "hello-world-env" workspace.deps.default;
in
mkApplication {
inherit venv;
from = pythonSet.hello;
} This hypothetical function would take a built environment, and only extract relevant bits given a package & a venv.
At some point you need an environment that lives somewhere.
pyproject.nix supports nixpkgs python builders, but uv2nix isn't using them at all. |
Yes, totally. For me, I think I'd want a helper that symlinks just the scripts of a given pyproject (the "hypothetical function ... [to] ... extract relevant bits given a package & a venv" you mentioned above). Feel free to close this, or leave this open to track implementing that hypothetical function.
Yes, totally. I meant that I want a wrapper on top of the venv. I don't mind the fact that there's a venv derivation realized in my |
The hello-world example provides a package like this:
If I
nix build
this, I get the followingresult/
:All the venv stuff in my
result/bin
directory feels unnecessary (in a less trivial project, it will even include scripts from my project's transitive dependencies). Theinclude/
,lib*/
,nix-support
, andpyvenv.cfg
stuff also feels unnecessary to me.Based on my reading of pyproject-nix, I suspect the way to do this is to invoke
lib.renderers.buildPythonPackage
+ nixpkgs'sbuildPythonApplication
. I tried massaging the hello-world example into doing just this, and I ended up with this:This seems to work, but feels kind of tedious and a little brittle (I've now got my
projectRoot
specified in 2 places). Is this the right approach? Is there a better way? (Happy to send in a PR if you point me in the right direction)The text was updated successfully, but these errors were encountered: