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

nixos-rebuild: do not resolve flake path #153515

Merged
merged 2 commits into from
Jan 8, 2022
Merged

nixos-rebuild: do not resolve flake path #153515

merged 2 commits into from
Jan 8, 2022

Conversation

thiagokokada
Copy link
Contributor

@thiagokokada thiagokokada commented Jan 4, 2022

Motivation for this change

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.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Jan 4, 2022
@thiagokokada
Copy link
Contributor Author

thiagokokada commented Jan 4, 2022

Tested nixos-rebuild switch inside and outside /run/opengl-driver/lib, works fine.

@thiagokokada
Copy link
Contributor Author

BTW, this should be backported to release-21.05 and release-21.11 since it also affects them. However to avoid the issue from #150065, in case this is merged I will wait sometime before backporting this to the respective branches.

@thiagokokada
Copy link
Contributor Author

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.
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Jan 4, 2022
Was only used in the code removed in commit
c274d04.
@thiagokokada
Copy link
Contributor Author

Also CC @TredwellGit to test if this cause issues with ZFS.

Copy link
Member

@figsoda figsoda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes the issue for me
would like it see another review since the other workaround caused issue on zfs

@thiagokokada
Copy link
Contributor Author

fixes the issue for me would like it see another review since the other workaround caused issue on zfs

CC @TredwellGit.

@cole-h cole-h removed their request for review January 7, 2022 18:47
Copy link
Member

@TredwellGit TredwellGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works with the ZFS modules.

@thiagokokada
Copy link
Contributor Author

Going to merge them and leave during some time on master branch to see if someone else detects some issues.

@thiagokokada thiagokokada merged commit 06235ce into NixOS:master Jan 8, 2022
@thiagokokada thiagokokada deleted the workaround-issue-144811 branch January 8, 2022 02:18
@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2022

Successfully created backport PR #153935 for release-21.11.

@Enzime
Copy link
Member

Enzime commented Jan 8, 2022

Awesome work, I ran into this a couple of times but I was too lazy to debug it, glad to see it was fixed 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants