-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
nix-shell -p is too magical #726
Comments
A general nix question that might turn out to be relevant: is https://github.com/NixOS/nix/blob/master/corepkgs/buildenv.nix used just by |
The nix expression used is constructed here: https://github.com/NixOS/nix/blob/master/scripts/nix-build.in#L225
|
@fkz thanks! Basically the same as I wrote above. 👍 |
Yes, so as an alternative to your suggestion, the following could be used instead:
This might still not be exactly what we want because we have to repeat this "import ./." for every single package we want to include. On the other hand, we can mix nixpkgs with our own, so things like the following are possible
|
The reason I ask my question is I wonder if nix-shell should by default just make an environment with the specified packages, and a CLI analogous to nix-env. There could be some function There is sort of a chicken-and-egg problem: "which is more fundamental to nix, setting up environments or building packages". I don't know what the answer is, but I think nix-shell should focus on exposing the more fundamental one whatever it is. |
@fkz nice! I didn't realise that was possible. Means we can do things like:
Thanks 👍 |
bump I just hit a wall with nix-shell -p as well until @copumpkin told me that I could use
which was what I needed in my scenario. |
Closing since |
When supplying a url to nix-shell: nix-shell https://github/tweag/nickel/archive/master.tar.gz It does not attempt to load the shell.nix file contained in the tarball, instead only loading default.nix, which fails if it doesn't provide a viable shell. I would expect the behavior to be consistent with launching from the base of a repository, namely, load shell.nix if it exists, default.nix otherwise. (see divnix/digga@e2172c8)
As an alternative, this works, though still quite verbose: $ nix-shell -E 'with (import ./pkgs.nix); mkShell { buildInputs = with gst_all_1; [ gstreamer gst-plugins-base gst-plugins-good ]; }' The aim here is to supply nixpkgs with project specific overlays to nix-shell with several packages. Whereas it works well for a single package ( I imagine it could work simply like this: $ nix-shell -p 'with (import ./pkgs.nix).gst_all_1; [ gstreamer gst-plugins-base gst-plugins-good ]' Moreover, it enters the shell but |
With
nix-shell -A
, I can pass it a .nix file to run expressions against, but I can't emulate that behavior easily withnix-shell -p
. For example,nix-shell -p foo
will installfoo
in my shell. If I runnix-shell '<nixpkgs>' -A foo
, that doesn't give me the same thing. If I want something similar, @puffnfresh on IRC suggested this nasty thing:which doesn't seem great. Can we have an easy way to get behavior like
-p
without relying onNIX_PATH
voodoo or the incantation above?The text was updated successfully, but these errors were encountered: