Why doesn't develop or shell have a pure mode?

I use to like entering a nix-shell --pure to verify that a package was pure and included all it’s required runtime dependencies.

How can I do this with the new nix commands?
nix develop or nix shell don’t seem to have anything similar except for --ignore-environment which is way more austere.

8 Likes

I saw @tomberek post `nix develop --pure` is not valid (nor is `nix shell --pure`) · Issue #4359 · NixOS/nix · GitHub
the discrepancy between the the facility of nix-shell --pure and what I can do here with nix develop or nix shell is surprising.

How else can I test that my runtime dependencies are all satisfied and correct?

4 Likes

I found nix shell --unset PATH not a bad solution.

5 Likes

Note that nix shell will not execute shellHooks, so if you’re making use of pkg-config, python packages, or anything else that really relies on hooks, then you’re SOL.

4 Likes

Sorry to bring up an old thread but if anyone is looking for a similar solution to isolate dev environments from the host system I found that adding the following to the top of your shell hook does the trick:

export PATH=$(for input in $buildInputs; do echo -n "$input/bin:"; done | sed 's/:$//')

This assumes all of the packages you are setting in your PATH are in the bin dir of the derivation output… Also, you really need to set everything, so you will likely need to add coreutils or busybox to make the shell usable.

If there is a better trick to this please let me know, would love to learn :smile:

1 Like

nix develop --ignore-environment

That will pretty much break the shell itself, I have never gotten that working.

2 Likes