Merge pull request #85029 from danielfullmer/systemd-boot-test
nixos/systemd-boot: Add basic test
This commit is contained in:
commit
cc91092f77
@ -189,9 +189,18 @@ let
|
|||||||
mkdir /boot/grub
|
mkdir /boot/grub
|
||||||
echo '(hd0) /dev/vda' > /boot/grub/device.map
|
echo '(hd0) /dev/vda' > /boot/grub/device.map
|
||||||
|
|
||||||
# Install GRUB and generate the GRUB boot menu.
|
# This is needed for systemd-boot to find ESP, and udev is not available here to create this
|
||||||
touch /etc/NIXOS
|
mkdir -p /dev/block
|
||||||
|
ln -s /dev/vda2 /dev/block/254:2
|
||||||
|
|
||||||
|
# Set up system profile (normally done by nixos-rebuild / nix-env --set)
|
||||||
mkdir -p /nix/var/nix/profiles
|
mkdir -p /nix/var/nix/profiles
|
||||||
|
ln -s ${config.system.build.toplevel} /nix/var/nix/profiles/system-1-link
|
||||||
|
ln -s /nix/var/nix/profiles/system-1-link /nix/var/nix/profiles/system
|
||||||
|
|
||||||
|
# Install bootloader
|
||||||
|
touch /etc/NIXOS
|
||||||
|
export NIXOS_INSTALL_BOOTLOADER=1
|
||||||
${config.system.build.toplevel}/bin/switch-to-configuration boot
|
${config.system.build.toplevel}/bin/switch-to-configuration boot
|
||||||
|
|
||||||
umount /boot
|
umount /boot
|
||||||
|
@ -297,6 +297,7 @@ in
|
|||||||
syncthing-relay = handleTest ./syncthing-relay.nix {};
|
syncthing-relay = handleTest ./syncthing-relay.nix {};
|
||||||
systemd = handleTest ./systemd.nix {};
|
systemd = handleTest ./systemd.nix {};
|
||||||
systemd-analyze = handleTest ./systemd-analyze.nix {};
|
systemd-analyze = handleTest ./systemd-analyze.nix {};
|
||||||
|
systemd-boot = handleTestOn ["x86_64-linux"] ./systemd-boot.nix {};
|
||||||
systemd-confinement = handleTest ./systemd-confinement.nix {};
|
systemd-confinement = handleTest ./systemd-confinement.nix {};
|
||||||
systemd-timesyncd = handleTest ./systemd-timesyncd.nix {};
|
systemd-timesyncd = handleTest ./systemd-timesyncd.nix {};
|
||||||
systemd-networkd-vrf = handleTest ./systemd-networkd-vrf.nix {};
|
systemd-networkd-vrf = handleTest ./systemd-networkd-vrf.nix {};
|
||||||
|
31
nixos/tests/systemd-boot.nix
Normal file
31
nixos/tests/systemd-boot.nix
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{ system ? builtins.currentSystem,
|
||||||
|
config ? {},
|
||||||
|
pkgs ? import ../.. { inherit system config; }
|
||||||
|
}:
|
||||||
|
|
||||||
|
with import ../lib/testing-python.nix { inherit system pkgs; };
|
||||||
|
with pkgs.lib;
|
||||||
|
|
||||||
|
makeTest {
|
||||||
|
name = "systemd-boot";
|
||||||
|
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ danielfullmer ];
|
||||||
|
|
||||||
|
machine = { pkgs, lib, ... }: {
|
||||||
|
virtualisation.useBootLoader = true;
|
||||||
|
virtualisation.useEFIBoot = true;
|
||||||
|
boot.loader.systemd-boot.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
machine.start()
|
||||||
|
machine.wait_for_unit("multi-user.target")
|
||||||
|
|
||||||
|
machine.succeed("test -e /boot/loader/entries/nixos-generation-1.conf")
|
||||||
|
|
||||||
|
# Ensure we actually booted using systemd-boot.
|
||||||
|
# Magic number is the vendor UUID used by systemd-boot.
|
||||||
|
machine.succeed(
|
||||||
|
"test -e /sys/firmware/efi/efivars/LoaderEntrySelected-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f"
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user