-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
nixos-rebuild: switch to tmpDir during rebuilds #150065
nixos-rebuild: switch to tmpDir during rebuilds #150065
Conversation
This is a workaround for issue #144811 until this issue is either fixed on nix itself.
This issue affects both |
would pushd and popd be better here? |
The issue of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I forgot to come back to this, fixes the issue for me
I really would like one more review here to make sure I am not breaking anything. |
Successfully created backport PR #150856 for |
Successfully created backport PR #150857 for |
This seems to break |
Let's revert it them. |
The removed lines converted the flake path passed by the command line from `/some/path` to `git+file:///some/path`. This technically shouldn't cause any issues, however running `nixos-rebuild switch` inside a directory `/nix/store` will cause the switch to fail and leave a partially construct generation (see issue #144811 for details). By itself this shouldn't be too much of an issue, however thanks to another issue in `systemd-boot-builder.py` this can leave the system in a broken state for those using `boot.loader.systemd-boot` (AFAIK the default), where future `nixos-rebuild switch` will fail (see issue #93694 for details). The issue can be fixed by running `nix-env -p /nix/var/nix/profiles/system --delete-generations old`, however this makes newbies very confused and it is showing in our support threads in Matrix and Discourse (see https://discourse.nixos.org/t/need-help-on-failure-of-building-my-configuration/16842). Keep in mind this is a workaround. The actual issue seems to be in nix itself (see: NixOS/nix#5510). See also #150065 for an alternative fix that caused other issues. Kudos for @figsoda for figuring out this fix. (cherry picked from commit c274d04)
Motivation for this change
Workaround issue: #144811
The idea of this fix is very simple: since running
nixos-rebuild
inside a symbolic link directory pointing to/nix/store
broke thenixos-rebuild
, what we are going to do instead is simply switch to another directory. We already create a temporary directorytmpDir
for some things, so we can switch to that directory without much loss.Keep in mind that this is a workaround. The actual issue seems to be how
nix
handles references withpath:
: NixOS/nix#5510I did a
nixos-rebuild switch
inside/run/opengl-driver/lib
and this workaround works fine. Also tested `nixos-rebuild {dry-build,dry-activate,build-vm,build-vm-with-bootloader,test,edit} commands and they seem to work fine, however I can't test remote builds and other functionality.Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes