[Nix-dev] Non-Garbage-Collected Development Environments

Bas van Dijk v.dijk.bas at gmail.com
Sun Dec 20 18:16:52 CET 2015


Hello,

At LumiGuide we're working on several projects. Each project has its
own attribute. To work on a project we can use nix-shell to enter a
development environment for that project like:

  nix-shell -A myProject

The problem is that once in a while our engineers need to garbage
collect their systems. When they run nix-collect-garbage some or all
of the dependencies of myProject might get collected. How can I
prevent this from happening?

I tried using the approach described in the wiki [1]. We can register
myProject.drv as a garbage collector root:

  $ nix-instantiate -A myProject \
      --indirect --add-root $PWD/myProject.drv

Then we can enter the environment using:

  $ nix-shell $PWD/myProject.drv

However, this doesn't prevent the dependencies from being collected
since myProject.drv only depends on the .drv files of the
dependencies, i.e. not the actual realized store paths.

I think myEnvFun might be the solution but the wiki mentions it's
deprecated. Does anybody know what I should use instead?

Cheers,

Bas

[1] https://nixos.org/wiki/Development_Environments


More information about the nix-dev mailing list