Skip to content
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 mangles options sent to nix-store #244

Closed
ttuegel opened this issue Apr 18, 2014 · 0 comments
Closed

nix-shell mangles options sent to nix-store #244

ttuegel opened this issue Apr 18, 2014 · 0 comments

Comments

@ttuegel
Copy link
Member

ttuegel commented Apr 18, 2014

man nix-shell says:

All options not listed here are passed to nix-store --realise, except for --arg and --attr / -A which are passed to nix-instantiate.

In fact, nix-shell tries to use everything as a path that doesn't begin with --. Observe:

$ nix-shell --add-root ./result --indirect
error: getting status of `./result': No such file or directory

(I've elided the full path to ./ above for clarity.)
OK, so with Nix 1.6, I would work around this by putting quotes around "--add-root ./result". Let's try that:

$ nix-shell "--add-root ./result" --indirect
error: unknown flag `--add-root result'
Try `nix-store --help' for more information.
/run/current-system/sw/bin/nix-shell: failed to build all dependencies

Alright, that's no good with Nix 1.7. The problem to begin with was that nix-shell thought result was the path to a Nix expression, and not an option for nix-store. So, I'll give it the path to an expression explicitly:

$ nix-shell default.nix --add-root ./result --indirect
error: path `./--indirect' is not a valid garbage collector root; it's not in the directory `/nix/var/nix/gcroots'
/run/current-system/sw/bin/nix-shell: failed to build all dependencies

What? Oh, ./result isn't being passed to nix-store after --add-root, even though nix-shell isn't using it as a path.

I need a way to pass arguments to nix-store through nix-shell. I suggest either or both of the following

  1. Have nix-shell take only the first path on the command line as the path to a Nix expression. Leave the rest of the command line alone. Then, my third command above would work.
  2. Use -- alone to terminate option parsing by nix-shell and pass everything thereafter directly to nix-store. Then I could use, e.g.,
nix-shell -- --add-root ./result --indirect
@ttuegel ttuegel changed the title nix-shell mangles options sent to nix-build nix-shell mangles options sent to nix-store Apr 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants