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

Bas van Dijk v.dijk.bas at gmail.com
Tue Dec 22 21:34:49 CET 2015


Hi Aristid,

That's exactly what I need, thanks!

It would be nice to get this documented.

Cheers,

Bas

On 22 December 2015 at 17:55, Aristid Breitkreuz <aristidb at gmail.com> wrote:
> nix-shell supports --add-root. The command should be something like this:
>
> nix-shell --indirect --add-root shell/deps
>
> (You should have a / in there to put all dependencies into a single
> directory, as it generates foo-1, foo-2... files.)
>
> Bas van Dijk <v.dijk.bas at gmail.com> schrieb am Di., 22. Dez. 2015 um 17:01
> Uhr:
>>
>> Thanks Tomasz! I didn't know about gc-keep-outputs. I'll try it out.
>>
>> On 20 December 2015 at 18:51, Tomasz Kontusz <tomasz.kontusz at gmail.com>
>> wrote:
>> > I think the nix-instantiate trick will only stop the GC if you have
>> > "gc-keep-outputs = true" in nix.conf.
>> >
>> > On 20.12.2015 18:16, Bas van Dijk wrote:
>> >> 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
>> >> _______________________________________________
>> >> nix-dev mailing list
>> >> nix-dev at lists.science.uu.nl
>> >> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>> >
>> > _______________________________________________
>> > nix-dev mailing list
>> > nix-dev at lists.science.uu.nl
>> > http://lists.science.uu.nl/mailman/listinfo/nix-dev
>> _______________________________________________
>> nix-dev mailing list
>> nix-dev at lists.science.uu.nl
>> http://lists.science.uu.nl/mailman/listinfo/nix-dev


More information about the nix-dev mailing list