summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Forsman <bjorn.forsman@gmail.com>2020-12-20 20:04:15 +0100
committerBjørn Forsman <bjorn.forsman@gmail.com>2020-12-21 08:55:13 +0100
commit39fad297fdc87f8718f654f0fdd01c4cacc5b1f8 (patch)
tree2f3646a62c2af893ebbb1f5f8bb20bec84ac9bdb
parentb1499452b8c7e0ae584e4bbfadd5b63836249bbf (diff)
nixos: fix "nixos-rebuild build-vm-with-bootloader" for EFI systems
`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 in qemu-vm.nix, when efi is needed. And remove the now unneeded configuration in ./nixos/tests/systemd-boot.nix, since it's handled globally. Before: * release-20.03: successful build, unsuccessful run * release-20.09 (and master): unsuccessful build After: * Successful build and run. Fixes https://github.com/NixOS/nixpkgs/issues/107255
-rw-r--r--nixos/modules/virtualisation/qemu-vm.nix4
-rw-r--r--nixos/tests/systemd-boot.nix1
2 files changed, 4 insertions, 1 deletions
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix
index 447d1f091c8c..b66ac1441864 100644
--- a/nixos/modules/virtualisation/qemu-vm.nix
+++ b/nixos/modules/virtualisation/qemu-vm.nix
@@ -605,6 +605,10 @@ in
virtualisation.bootDevice = mkDefault (driveDeviceName 1);
+ virtualisation.useEFIBoot = mkDefault
+ (config.boot.loader.systemd-boot.enable ||
+ config.boot.loader.efi.canTouchEfiVariables);
+
virtualisation.pathsInNixDB = [ config.system.build.toplevel ];
# FIXME: Consolidate this one day.
diff --git a/nixos/tests/systemd-boot.nix b/nixos/tests/systemd-boot.nix
index 7a663dd9b428..a37c87bccc28 100644
--- a/nixos/tests/systemd-boot.nix
+++ b/nixos/tests/systemd-boot.nix
@@ -9,7 +9,6 @@ with pkgs.lib;
let
common = {
virtualisation.useBootLoader = true;
- virtualisation.useEFIBoot = true;
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
environment.systemPackages = [ pkgs.efibootmgr ];