Navigation Menu

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: fix "nixos-rebuild build-vm-with-bootloader" for EFI systems (v2) #108504

Merged

Conversation

bjornfor
Copy link
Contributor

@bjornfor bjornfor commented Jan 5, 2021

Motivation for this change

(The first version of this change, in commit 39fad29, broke
nix-build -A nixosTests.installer.simpleUefiSystemdBoot. This is the
2nd version, which hopefully does not break anything.)

nixos-rebuild build-vm-with-bootloader currently fails with the
default NixOS EFI configuration:

$ cat >configuration.nix <<EOF
{
fileSystems."/".device = "/dev/sda1";
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
}
EOF

$ nixos-rebuild build-vm-with-bootloader -I nixos-config=$PWD/configuration.nix -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.09.tar.gz
[...]
insmod: ERROR: could not insert module /nix/store/1ibmgfr13r8b6xyn4f0wj115819f359c-linux-5.4.83/lib/modules/5.4.83/kernel/fs/efivarfs/efivarfs.ko.xz: No such device
mount: /sys/firmware/efi/efivars: mount point does not exist.
[ 1.908328] reboot: Power down
builder for '/nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv' failed with exit code 32
[...]

Fix it by setting virtualisation.useEFIBoot = true when needed.

Before:

  • release-20.03: successful build, unsuccessful run
  • release-20.09 (and master): unsuccessful build

After:

  • Successful build and run.

Fixes #107255

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

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

Please also add this fix to the flake.nix:

{ virtualisation.useBootLoader = true; }

(The first version of this change, in commit 39fad29, broke
`nix-build -A nixosTests.installer.simpleUefiSystemdBoot`. This is the
2nd version, which hopefully does not break anything.)

`nixos-rebuild build-vm-with-bootloader` currently fails with the
default NixOS EFI configuration:

  $ cat >configuration.nix <<EOF
  {
    fileSystems."/".device = "/dev/sda1";
    boot.loader.systemd-boot.enable = true;
    boot.loader.efi.canTouchEfiVariables = true;
  }
  EOF

  $ nixos-rebuild build-vm-with-bootloader -I nixos-config=$PWD/configuration.nix -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.09.tar.gz
  [...]
  insmod: ERROR: could not insert module /nix/store/1ibmgfr13r8b6xyn4f0wj115819f359c-linux-5.4.83/lib/modules/5.4.83/kernel/fs/efivarfs/efivarfs.ko.xz: No such device
  mount: /sys/firmware/efi/efivars: mount point does not exist.
  [    1.908328] reboot: Power down
  builder for '/nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv' failed with exit code 32
  [...]

Fix it by setting virtualisation.useEFIBoot = true when needed.

Before:
* release-20.03: successful build, unsuccessful run
* release-20.09 (and master): unsuccessful build

After:
* Successful build and run.

Fixes NixOS#107255
@bjornfor bjornfor force-pushed the fix-build-vm-with-bootloader-with-efi-v2 branch from 1163445 to 0956c50 Compare January 8, 2021 06:58
@bjornfor
Copy link
Contributor Author

bjornfor commented Jan 8, 2021

Please also add this fix to the flake.nix:

Done.

Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

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

Diff LGTM.

@bjornfor bjornfor merged commit 72d906a into NixOS:master Jan 8, 2021
@bjornfor bjornfor deleted the fix-build-vm-with-bootloader-with-efi-v2 branch January 8, 2021 18:36
@bjornfor bjornfor changed the title nixos: fix "nixos-rebuild build-vm-with-bootloader" for EFI systems nixos: fix "nixos-rebuild build-vm-with-bootloader" for EFI systems (v2) Jan 10, 2021
@bjornfor
Copy link
Contributor Author

Backported to release-20.09 (9148817) now that the nixos-unstable channel has updated (all tests passed).

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

Successfully merging this pull request may close these issues.

"nixos-rebuild build-vm-with-booloader" with systemd-boot is broken again
2 participants