Skip to content

nix-env should add to auto gcroots #148

Closed as not planned
Closed as not planned

Description

@chaoflow

nix-build (a perl script) calls nix-store with --add-root and--indirect. These results in theresultlinks to be referenced in/nix/var/nix/gcroots/auto` and therefore protects them from garbage collection.

It would be nice to do the same for nix-env.

Activity

  1. zokrezyl commented on Oct 4, 2019

    @zokrezyl

    Hi, any progress about this topic? I had to implement already few times hacks like:

    -> either using nix-build with --add-root but then reinvent the wheel and add the nix-env details on top of it (hack!)
    -> use nix-env and add manually the gcroots, this is again hackish

    In extreme case I could contribute with a PR, but not clear what was the initial design intention.

    I would find this as a powerful feature when you want for instance to use shared /nix for containers (with for read only /nix) where you prepare an env for the container, you run the container(Z) and then you do garbage collection time to time.

    Thanks in advance for clarification.

  2. edolstra commented on Oct 4, 2019

    @edolstra
    Member

    Profiles should be created in a directory searched for GC roots, such as /nix/var/nix/profiles. I guess it would be good if Nix warned if a profile is not in such a directory.

  3. stale commented on Feb 16, 2021

    @stale

    I marked this as stale due to inactivity. → More info

  4. stale commented on Apr 30, 2022

    @stale

    I closed this issue due to inactivity. → More info

  5. removed their assignment
    on Apr 26, 2024
  6. added a commit that references this issue on Jul 25, 2025
  7. added a commit that references this issue on Aug 5, 2026
  8. tomberek commented on Aug 13, 2026

    @tomberek
    Contributor

    Closing as stale. Re-open if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions