[Nix-dev] truly persistent nix-shell

Ruben Astudillo ruben.astud at gmail.com
Sun Nov 20 19:00:55 CET 2016


On 20/11/16 10:41, Andreas Herrmann wrote:
> It is possible to avoid this issue by creating a gc-root for every
package that the nix-shell pulls in:
>
>     $ nix-store -r $(nix-store --query --references $PWD/shell.drv) \
>         --indirect --add-root $PWD/shell.dep
>
> Best, Andreas
>
>
> [1]: https://gist.github.com/aherrmann/51b56283f9ed5853747908fbab907316
> [2]:
https://nixos.org/wiki/Development_Environments#Making_a_Persistent_nix-shell_Environment

I've also searched for ways to persist gc on environments. This works!,
I read the links you posted, and seeing the comments and references they
provide the following answer [3]

        $ cd <my-project>
        $ mkdir gcroots
        $ nix-shell ./shell.nix --pure --indirect --add-root gcroots/dep
        $ exit
        $ nix-collect-garbage
        $ nix-shell ./shell.nix

So this maybe makes you command redundant (although less obsucure than
this commands). Maybe is worthwhile document this behaviour & simplify
the flags to nix-shell to obtain this result?

[3]: https://github.com/NixOS/nixpkgs/issues/5623#issuecomment-74048047
-- 
-- Ruben


More information about the nix-dev mailing list