Loading nixos/tests/all-tests.nix +1 −1 Original line number Diff line number Diff line Loading @@ -1417,7 +1417,7 @@ in systemd = runTest ./systemd.nix; systemd-analyze = runTest ./systemd-analyze.nix; systemd-binfmt = handleTestOn [ "x86_64-linux" ] ./systemd-binfmt.nix { }; systemd-boot = handleTest ./systemd-boot.nix { }; systemd-boot = import ./systemd-boot.nix { inherit runTest runTestOn; }; systemd-bpf = runTest ./systemd-bpf.nix; systemd-capsules = runTest ./systemd-capsules.nix; systemd-confinement = handleTest ./systemd-confinement { }; Loading nixos/tests/systemd-boot.nix +482 −429 Original line number Diff line number Diff line { system ? builtins.currentSystem, config ? { }, pkgs ? import ../.. { inherit system config; }, runTest, runTestOn, ... }: with import ../lib/testing-python.nix { inherit system pkgs; }; with pkgs.lib; let common = { common = { pkgs, ... }: { virtualisation.useBootLoader = true; virtualisation.useEFIBoot = true; boot.loader.systemd-boot.enable = true; Loading @@ -32,6 +31,9 @@ let partitionTableType = "efixbootldr"; touchEFIVars = true; installBootLoader = true; # Don't copy the channel to avoid rebuilding this image, and all tests # that use it, every time that nixpkgs changes copyChannel = false; }; in { Loading Loading @@ -90,9 +92,11 @@ let ''; in { basic = makeTest { basic = runTest ( { lib, ... }: { name = "systemd-boot"; meta.maintainers = with pkgs.lib.maintainers; [ meta.maintainers = with lib.maintainers; [ danielfullmer julienmalka ]; Loading @@ -115,23 +119,28 @@ in # "bootctl install" should have created an EFI entry machine.succeed('efibootmgr | grep "Linux Boot Manager"') ''; }; } ); # Test that systemd-boot works with secure boot secureBoot = makeTest { secureBoot = runTest ( { pkgs, lib, ... }: { name = "systemd-boot-secure-boot"; nodes.machine = { nodes.machine = { pkgs, ... }: { imports = [ common ]; environment.systemPackages = [ pkgs.sbctl ]; virtualisation.useSecureBoot = true; }; testScript = { nodes, ... }: let efiArch = pkgs.stdenv.hostPlatform.efiArch; in { nodes, ... }: '' machine.start(allow_reboot=True) machine.wait_for_unit("multi-user.target") Loading @@ -139,18 +148,21 @@ in machine.succeed("sbctl create-keys") machine.succeed("sbctl enroll-keys --yes-this-might-brick-my-machine") machine.succeed('sbctl sign /boot/EFI/systemd/systemd-boot${efiArch}.efi') machine.succeed('sbctl sign /boot/EFI/BOOT/BOOT${toUpper efiArch}.EFI') machine.succeed('sbctl sign /boot/EFI/BOOT/BOOT${lib.toUpper efiArch}.EFI') machine.succeed('sbctl sign /boot/EFI/nixos/*${nodes.machine.system.boot.loader.kernelFile}.efi') machine.reboot() assert "Secure Boot: enabled (user)" in machine.succeed("bootctl status") ''; }; } ); basicXbootldr = makeTest { basicXbootldr = runTest ( { lib, ... }: { name = "systemd-boot-xbootldr"; meta.maintainers = with pkgs.lib.maintainers; [ sdht0 ]; meta.maintainers = with lib.maintainers; [ sdht0 ]; nodes.machine = commonXbootldr; Loading @@ -174,12 +186,15 @@ in # "bootctl install" should have created an EFI entry machine.succeed('efibootmgr | grep "Linux Boot Manager"') ''; }; } ); # Check that specialisations create corresponding boot entries. specialisation = makeTest { specialisation = runTest ( { pkgs, lib, ... }: { name = "systemd-boot-specialisation"; meta.maintainers = with pkgs.lib.maintainers; [ meta.maintainers = with lib.maintainers; [ lukegb julienmalka ]; Loading Loading @@ -229,12 +244,15 @@ in r"grep 'devicetree /EFI/nixos/[a-z0-9]\{32\}.*dummy' /boot/loader/entries/nixos-generation-1-specialisation-something.conf" ) ''; }; } ); # Boot without having created an EFI entry--instead using default "/EFI/BOOT/BOOTX64.EFI" fallback = makeTest { fallback = runTest ( { pkgs, lib, ... }: { name = "systemd-boot-fallback"; meta.maintainers = with pkgs.lib.maintainers; [ meta.maintainers = with lib.maintainers; [ danielfullmer julienmalka ]; Loading @@ -243,7 +261,7 @@ in { pkgs, lib, ... }: { imports = [ common ]; boot.loader.efi.canTouchEfiVariables = mkForce false; boot.loader.efi.canTouchEfiVariables = lib.mkForce false; }; testScript = '' Loading @@ -261,11 +279,14 @@ in # "bootctl install" should _not_ have created an EFI entry machine.fail('efibootmgr | grep "Linux Boot Manager"') ''; }; } ); update = makeTest { update = runTest ( { lib, ... }: { name = "systemd-boot-update"; meta.maintainers = with pkgs.lib.maintainers; [ meta.maintainers = with lib.maintainers; [ danielfullmer julienmalka ]; Loading Loading @@ -301,13 +322,14 @@ in assert 'to "/boot/EFI/systemd/systemd-bootx64.efi"' in output, "systemd-boot not copied to to /boot/EFI/systemd/systemd-bootx64.efi" assert 'to "/boot/EFI/BOOT/BOOTX64.EFI"' in output, "systemd-boot not copied to to /boot/EFI/BOOT/BOOTX64.EFI" ''; }; } ); memtest86 = with pkgs.lib; optionalAttrs (meta.availableOn { inherit system; } pkgs.memtest86plus) (makeTest { memtest86 = runTestOn [ "x86_64-linux" ] ( { lib, ... }: { name = "systemd-boot-memtest86"; meta.maintainers = with maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes.machine = { pkgs, lib, ... }: Loading @@ -320,11 +342,14 @@ in machine.succeed("test -e /boot/loader/entries/memtest86.conf") machine.succeed("test -e /boot/efi/memtest86/memtest.efi") ''; }); } ); netbootxyz = makeTest { netbootxyz = runTest ( { lib, ... }: { name = "systemd-boot-netbootxyz"; meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes.machine = { pkgs, lib, ... }: Loading @@ -337,11 +362,14 @@ in machine.succeed("test -e /boot/loader/entries/netbootxyz.conf") machine.succeed("test -e /boot/efi/netbootxyz/netboot.xyz.efi") ''; }; } ); edk2-uefi-shell = makeTest { edk2-uefi-shell = runTest ( { lib, ... }: { name = "systemd-boot-edk2-uefi-shell"; meta.maintainers = with pkgs.lib.maintainers; [ iFreilicht ]; meta.maintainers = with lib.maintainers; [ iFreilicht ]; nodes.machine = { ... }: Loading @@ -354,11 +382,14 @@ in machine.succeed("test -e /boot/loader/entries/edk2-uefi-shell.conf") machine.succeed("test -e /boot/efi/edk2-uefi-shell/shell.efi") ''; }; } ); windows = makeTest { windows = runTest ( { lib, ... }: { name = "systemd-boot-windows"; meta.maintainers = with pkgs.lib.maintainers; [ iFreilicht ]; meta.maintainers = with lib.maintainers; [ iFreilicht ]; nodes.machine = { ... }: Loading Loading @@ -401,11 +432,14 @@ in machine.succeed("grep 'title Windows Ten' /boot/loader/entries/windows_Ten.conf") machine.succeed('grep "title Title with-_-punctuation ...?!" /boot/loader/entries/windows_11.conf') ''; }; } ); memtestSortKey = makeTest { memtestSortKey = runTest ( { lib, ... }: { name = "systemd-boot-memtest-sortkey"; meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes.machine = { pkgs, lib, ... }: Loading @@ -420,11 +454,14 @@ in machine.succeed("test -e /boot/efi/memtest86/memtest.efi") machine.succeed("grep 'sort-key apple' /boot/loader/entries/memtest86.conf") ''; }; } ); entryFilenameXbootldr = makeTest { entryFilenameXbootldr = runTest ( { lib, ... }: { name = "systemd-boot-entry-filename-xbootldr"; meta.maintainers = with pkgs.lib.maintainers; [ sdht0 ]; meta.maintainers = with lib.maintainers; [ sdht0 ]; nodes.machine = { pkgs, lib, ... }: Loading @@ -445,11 +482,14 @@ in machine.succeed("test -e /boot/loader/entries/memtest86.conf") machine.succeed("test -e /boot/EFI/memtest86/memtest.efi") ''; }; } ); extraEntries = makeTest { extraEntries = runTest ( { lib, ... }: { name = "systemd-boot-extra-entries"; meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes.machine = { pkgs, lib, ... }: Loading @@ -466,11 +506,14 @@ in machine.succeed("test -e /boot/loader/entries/banana.conf") machine.succeed("test -e /boot/efi/nixos/.extra-files/loader/entries/banana.conf") ''; }; } ); extraFiles = makeTest { extraFiles = runTest ( { lib, ... }: { name = "systemd-boot-extra-files"; meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes.machine = { pkgs, lib, ... }: Loading @@ -485,11 +528,14 @@ in machine.succeed("test -e /boot/efi/fruits/tomato.efi") machine.succeed("test -e /boot/efi/nixos/.extra-files/efi/fruits/tomato.efi") ''; }; } ); switch-test = makeTest { switch-test = runTest ( { lib, ... }: { name = "systemd-boot-switch-test"; meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes = { inherit common; Loading Loading @@ -550,11 +596,14 @@ in machine.succeed("test -e /boot/efi/nixos/.extra-files/loader/entries/netbootxyz.conf") machine.succeed("test -e /boot/efi/nixos/.extra-files/efi/netbootxyz/netboot.xyz.efi") ''; }; } ); garbage-collect-entry = makeTest { garbage-collect-entry = runTest ( { lib, ... }: { name = "systemd-boot-garbage-collect-entry"; meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes = { inherit common; Loading Loading @@ -582,11 +631,14 @@ in machine.fail("test -e /boot/loader/entries/nixos-generation-1.conf") machine.succeed("test -e /boot/loader/entries/nixos-generation-2.conf") ''; }; } ); no-bootspec = makeTest { no-bootspec = runTest ( { lib, ... }: { name = "systemd-boot-no-bootspec"; meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes.machine = { imports = [ common ]; Loading @@ -597,5 +649,6 @@ in machine.start() machine.wait_for_unit("multi-user.target") ''; }; } ); } Loading
nixos/tests/all-tests.nix +1 −1 Original line number Diff line number Diff line Loading @@ -1417,7 +1417,7 @@ in systemd = runTest ./systemd.nix; systemd-analyze = runTest ./systemd-analyze.nix; systemd-binfmt = handleTestOn [ "x86_64-linux" ] ./systemd-binfmt.nix { }; systemd-boot = handleTest ./systemd-boot.nix { }; systemd-boot = import ./systemd-boot.nix { inherit runTest runTestOn; }; systemd-bpf = runTest ./systemd-bpf.nix; systemd-capsules = runTest ./systemd-capsules.nix; systemd-confinement = handleTest ./systemd-confinement { }; Loading
nixos/tests/systemd-boot.nix +482 −429 Original line number Diff line number Diff line { system ? builtins.currentSystem, config ? { }, pkgs ? import ../.. { inherit system config; }, runTest, runTestOn, ... }: with import ../lib/testing-python.nix { inherit system pkgs; }; with pkgs.lib; let common = { common = { pkgs, ... }: { virtualisation.useBootLoader = true; virtualisation.useEFIBoot = true; boot.loader.systemd-boot.enable = true; Loading @@ -32,6 +31,9 @@ let partitionTableType = "efixbootldr"; touchEFIVars = true; installBootLoader = true; # Don't copy the channel to avoid rebuilding this image, and all tests # that use it, every time that nixpkgs changes copyChannel = false; }; in { Loading Loading @@ -90,9 +92,11 @@ let ''; in { basic = makeTest { basic = runTest ( { lib, ... }: { name = "systemd-boot"; meta.maintainers = with pkgs.lib.maintainers; [ meta.maintainers = with lib.maintainers; [ danielfullmer julienmalka ]; Loading @@ -115,23 +119,28 @@ in # "bootctl install" should have created an EFI entry machine.succeed('efibootmgr | grep "Linux Boot Manager"') ''; }; } ); # Test that systemd-boot works with secure boot secureBoot = makeTest { secureBoot = runTest ( { pkgs, lib, ... }: { name = "systemd-boot-secure-boot"; nodes.machine = { nodes.machine = { pkgs, ... }: { imports = [ common ]; environment.systemPackages = [ pkgs.sbctl ]; virtualisation.useSecureBoot = true; }; testScript = { nodes, ... }: let efiArch = pkgs.stdenv.hostPlatform.efiArch; in { nodes, ... }: '' machine.start(allow_reboot=True) machine.wait_for_unit("multi-user.target") Loading @@ -139,18 +148,21 @@ in machine.succeed("sbctl create-keys") machine.succeed("sbctl enroll-keys --yes-this-might-brick-my-machine") machine.succeed('sbctl sign /boot/EFI/systemd/systemd-boot${efiArch}.efi') machine.succeed('sbctl sign /boot/EFI/BOOT/BOOT${toUpper efiArch}.EFI') machine.succeed('sbctl sign /boot/EFI/BOOT/BOOT${lib.toUpper efiArch}.EFI') machine.succeed('sbctl sign /boot/EFI/nixos/*${nodes.machine.system.boot.loader.kernelFile}.efi') machine.reboot() assert "Secure Boot: enabled (user)" in machine.succeed("bootctl status") ''; }; } ); basicXbootldr = makeTest { basicXbootldr = runTest ( { lib, ... }: { name = "systemd-boot-xbootldr"; meta.maintainers = with pkgs.lib.maintainers; [ sdht0 ]; meta.maintainers = with lib.maintainers; [ sdht0 ]; nodes.machine = commonXbootldr; Loading @@ -174,12 +186,15 @@ in # "bootctl install" should have created an EFI entry machine.succeed('efibootmgr | grep "Linux Boot Manager"') ''; }; } ); # Check that specialisations create corresponding boot entries. specialisation = makeTest { specialisation = runTest ( { pkgs, lib, ... }: { name = "systemd-boot-specialisation"; meta.maintainers = with pkgs.lib.maintainers; [ meta.maintainers = with lib.maintainers; [ lukegb julienmalka ]; Loading Loading @@ -229,12 +244,15 @@ in r"grep 'devicetree /EFI/nixos/[a-z0-9]\{32\}.*dummy' /boot/loader/entries/nixos-generation-1-specialisation-something.conf" ) ''; }; } ); # Boot without having created an EFI entry--instead using default "/EFI/BOOT/BOOTX64.EFI" fallback = makeTest { fallback = runTest ( { pkgs, lib, ... }: { name = "systemd-boot-fallback"; meta.maintainers = with pkgs.lib.maintainers; [ meta.maintainers = with lib.maintainers; [ danielfullmer julienmalka ]; Loading @@ -243,7 +261,7 @@ in { pkgs, lib, ... }: { imports = [ common ]; boot.loader.efi.canTouchEfiVariables = mkForce false; boot.loader.efi.canTouchEfiVariables = lib.mkForce false; }; testScript = '' Loading @@ -261,11 +279,14 @@ in # "bootctl install" should _not_ have created an EFI entry machine.fail('efibootmgr | grep "Linux Boot Manager"') ''; }; } ); update = makeTest { update = runTest ( { lib, ... }: { name = "systemd-boot-update"; meta.maintainers = with pkgs.lib.maintainers; [ meta.maintainers = with lib.maintainers; [ danielfullmer julienmalka ]; Loading Loading @@ -301,13 +322,14 @@ in assert 'to "/boot/EFI/systemd/systemd-bootx64.efi"' in output, "systemd-boot not copied to to /boot/EFI/systemd/systemd-bootx64.efi" assert 'to "/boot/EFI/BOOT/BOOTX64.EFI"' in output, "systemd-boot not copied to to /boot/EFI/BOOT/BOOTX64.EFI" ''; }; } ); memtest86 = with pkgs.lib; optionalAttrs (meta.availableOn { inherit system; } pkgs.memtest86plus) (makeTest { memtest86 = runTestOn [ "x86_64-linux" ] ( { lib, ... }: { name = "systemd-boot-memtest86"; meta.maintainers = with maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes.machine = { pkgs, lib, ... }: Loading @@ -320,11 +342,14 @@ in machine.succeed("test -e /boot/loader/entries/memtest86.conf") machine.succeed("test -e /boot/efi/memtest86/memtest.efi") ''; }); } ); netbootxyz = makeTest { netbootxyz = runTest ( { lib, ... }: { name = "systemd-boot-netbootxyz"; meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes.machine = { pkgs, lib, ... }: Loading @@ -337,11 +362,14 @@ in machine.succeed("test -e /boot/loader/entries/netbootxyz.conf") machine.succeed("test -e /boot/efi/netbootxyz/netboot.xyz.efi") ''; }; } ); edk2-uefi-shell = makeTest { edk2-uefi-shell = runTest ( { lib, ... }: { name = "systemd-boot-edk2-uefi-shell"; meta.maintainers = with pkgs.lib.maintainers; [ iFreilicht ]; meta.maintainers = with lib.maintainers; [ iFreilicht ]; nodes.machine = { ... }: Loading @@ -354,11 +382,14 @@ in machine.succeed("test -e /boot/loader/entries/edk2-uefi-shell.conf") machine.succeed("test -e /boot/efi/edk2-uefi-shell/shell.efi") ''; }; } ); windows = makeTest { windows = runTest ( { lib, ... }: { name = "systemd-boot-windows"; meta.maintainers = with pkgs.lib.maintainers; [ iFreilicht ]; meta.maintainers = with lib.maintainers; [ iFreilicht ]; nodes.machine = { ... }: Loading Loading @@ -401,11 +432,14 @@ in machine.succeed("grep 'title Windows Ten' /boot/loader/entries/windows_Ten.conf") machine.succeed('grep "title Title with-_-punctuation ...?!" /boot/loader/entries/windows_11.conf') ''; }; } ); memtestSortKey = makeTest { memtestSortKey = runTest ( { lib, ... }: { name = "systemd-boot-memtest-sortkey"; meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes.machine = { pkgs, lib, ... }: Loading @@ -420,11 +454,14 @@ in machine.succeed("test -e /boot/efi/memtest86/memtest.efi") machine.succeed("grep 'sort-key apple' /boot/loader/entries/memtest86.conf") ''; }; } ); entryFilenameXbootldr = makeTest { entryFilenameXbootldr = runTest ( { lib, ... }: { name = "systemd-boot-entry-filename-xbootldr"; meta.maintainers = with pkgs.lib.maintainers; [ sdht0 ]; meta.maintainers = with lib.maintainers; [ sdht0 ]; nodes.machine = { pkgs, lib, ... }: Loading @@ -445,11 +482,14 @@ in machine.succeed("test -e /boot/loader/entries/memtest86.conf") machine.succeed("test -e /boot/EFI/memtest86/memtest.efi") ''; }; } ); extraEntries = makeTest { extraEntries = runTest ( { lib, ... }: { name = "systemd-boot-extra-entries"; meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes.machine = { pkgs, lib, ... }: Loading @@ -466,11 +506,14 @@ in machine.succeed("test -e /boot/loader/entries/banana.conf") machine.succeed("test -e /boot/efi/nixos/.extra-files/loader/entries/banana.conf") ''; }; } ); extraFiles = makeTest { extraFiles = runTest ( { lib, ... }: { name = "systemd-boot-extra-files"; meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes.machine = { pkgs, lib, ... }: Loading @@ -485,11 +528,14 @@ in machine.succeed("test -e /boot/efi/fruits/tomato.efi") machine.succeed("test -e /boot/efi/nixos/.extra-files/efi/fruits/tomato.efi") ''; }; } ); switch-test = makeTest { switch-test = runTest ( { lib, ... }: { name = "systemd-boot-switch-test"; meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes = { inherit common; Loading Loading @@ -550,11 +596,14 @@ in machine.succeed("test -e /boot/efi/nixos/.extra-files/loader/entries/netbootxyz.conf") machine.succeed("test -e /boot/efi/nixos/.extra-files/efi/netbootxyz/netboot.xyz.efi") ''; }; } ); garbage-collect-entry = makeTest { garbage-collect-entry = runTest ( { lib, ... }: { name = "systemd-boot-garbage-collect-entry"; meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes = { inherit common; Loading Loading @@ -582,11 +631,14 @@ in machine.fail("test -e /boot/loader/entries/nixos-generation-1.conf") machine.succeed("test -e /boot/loader/entries/nixos-generation-2.conf") ''; }; } ); no-bootspec = makeTest { no-bootspec = runTest ( { lib, ... }: { name = "systemd-boot-no-bootspec"; meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ]; meta.maintainers = with lib.maintainers; [ julienmalka ]; nodes.machine = { imports = [ common ]; Loading @@ -597,5 +649,6 @@ in machine.start() machine.wait_for_unit("multi-user.target") ''; }; } ); }