Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix-build: --add-root ignored #1982

Closed
lheckemann opened this issue Mar 16, 2018 · 12 comments · Fixed by #7103
Closed

nix-build: --add-root ignored #1982

lheckemann opened this issue Mar 16, 2018 · 12 comments · Fixed by #7103
Assignees
Labels
error-messages Confusing messages and better diagnostics stale

Comments

@lheckemann
Copy link
Member

lheckemann commented Mar 16, 2018

What I did: nix-build '<nixpkgs>' -A hello --add-root test
Expected behaviour: test symlink to exist afterwards, or perhaps an error message complaining that --add-root is not a recognised option, or pointing me to -o
Actual behaviour: result symlink, no test symlink, no error message

@ElvishJerricco
Copy link
Contributor

ElvishJerricco commented Mar 16, 2018

Same thing with nix-shell. -o test doesn't create any symlink either. I think this is pretty serious in the nix-shell case, since now a common technique just silently fails.

@bdesham
Copy link

bdesham commented Apr 18, 2020

Is there any kind of workaround for this? Is it possible to create a GC root manually?

(I’m running into this issue in the context of commercialhaskell/stack#4673. I have to run nix-store --gc every so often, because I don’t have that much drive space left, but then the next build of my Stack-based Haskell project takes 10 minutes of maxing out all of my CPU cores.)

@lheckemann
Copy link
Member Author

@bdesham yes, nix-build will create a result symlink and make it a GC root by default. You can change the name of the symlink with the -o option. The issue I'm describing here is that the --add-root option is silently ignored instead of erroring or similar.

You have multiple ways available for creating GC roots:

  • Installing paths in your user profile, system profile, or home profile using nix-env or configuration.nix or home-manager respectively
  • using nix-build's default behaviour, with or without -o
  • using nix-store -r /nix/store/$hash-$name --add-root ./root-name --indirect
  • manually by making symlinks in /nix/var/nix/gcroots — I used this in a terribly ugly script at one point to root an entire build closure: https://github.com/lheckemann/dotfiles/blob/master/gcroots.sh

@domenkozar domenkozar added error-messages Confusing messages and better diagnostics and removed backlog labels Apr 19, 2020
@jakubgs
Copy link

jakubgs commented Jun 19, 2020

I just wasted like an hour trying to figure out what I was doing wrong. Turns out nix-build just silently ignores --add-root. Not cool. It appears that nix-shell also ignores it.

@zimbatm
Copy link
Member

zimbatm commented Jun 19, 2020

lol, @jakubgs. I guess the thousands of hours that other people spent on the project don't count in the balance.

@jakubgs
Copy link

jakubgs commented Jun 19, 2020

How did you read that from my comment?

@stale
Copy link

stale bot commented Feb 13, 2021

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

@stale stale bot added the stale label Feb 13, 2021
@bdesham
Copy link

bdesham commented Feb 13, 2021

This is still a problem.

@stale stale bot removed the stale label Feb 13, 2021
@stale
Copy link

stale bot commented Aug 13, 2021

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

@stale stale bot added the stale label Aug 13, 2021
@jakubgs
Copy link

jakubgs commented Aug 13, 2021

No.

@stale stale bot removed the stale label Aug 13, 2021
@burdiyan
Copy link

I was trying to create a gcroot for my nix-shell configuration, and the problem is that nix-build doesn't work with nix-shell because it explicitly fails inside the buildPhase. So I thought that nix-instantiate would do the trick if I use it with --add-root <something> --indirect. It created the symlink for the derivation of the nix-shell, but this didn't work and everything was garbage collected.

I know that nix develop creates gcroots automatically, but creating one for nix-shell should be easier (or at least possible without trial and error).

@vincentbernat
Copy link
Member

For me, nix develop does not create a root either.

@stale stale bot added the stale label Aug 12, 2022
lheckemann added a commit to lheckemann/nix that referenced this issue Sep 26, 2022
rapenne-s pushed a commit to rapenne-s/nix that referenced this issue Oct 28, 2022
Minion3665 pushed a commit to Minion3665/nix that referenced this issue Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error-messages Confusing messages and better diagnostics stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants