nixos-rebuild: do not resolve flake path#153515
nixos-rebuild: do not resolve flake path#153515thiagokokada merged 2 commits intoNixOS:masterfrom thiagokokada:workaround-issue-144811
Conversation
|
Tested |
|
BTW, this should be backported to |
|
CC @edolstra and @cole-h since they're the folks that introduced the lines that are being deleted on this PR. CC @colemickens @figsoda to help testing. |
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.
Was only used in the code removed in commit c274d04.
|
Also CC @TredwellGit to test if this cause issues with ZFS. |
figsoda
left a comment
There was a problem hiding this comment.
fixes the issue for me
would like it see another review since the other workaround caused issue on zfs
CC @TredwellGit. |
TredwellGit
left a comment
There was a problem hiding this comment.
This works with the ZFS modules.
|
Going to merge them and leave during some time on |
|
Successfully created backport PR #153935 for |
|
Awesome work, I ran into this a couple of times but I was too lazy to debug it, glad to see it was fixed 🎉 |
PR NixOS#375493 was introduced to fix an issue of different behavior between `nixos-rebuild repl` and `nixos-rebuild switch` by forcing usage of `git+file://` protocol when evaluating the Flake. This sadly reintroduced an older issue from the original `nixos-rebuild` that is caused by a pretty nasty bug in `nix`: - NixOS#144811 Let's do the same fix we did for `nixos-rebuild` and just stopping normalizing the Flake (NixOS#153515). This will bring back the original issues this code is supposed to fix, but I argue that a difference between `nixos-rebuild repl` and `nixos-rebuild switch` is better than having a broken system.
Motivation for this change
The removed lines converted the flake path passed by the command line from
/some/pathtogit+file:///some/path.This technically shouldn't cause any issues, however running
nixos-rebuild switchinside a directory/nix/storewill 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.pythis can leave the system in a broken state for those usingboot.loader.systemd-boot(AFAIK the default), where futurenixos-rebuild switchwill 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.
Things done
sandbox = trueset 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.shto update generated release notes