Merge pull request #169113 from ElvishJerricco/systemd-stage-1-installer-tests

nixos: Installer tests for systemd stage 1

Changed files
+61 -2
nixos
modules
installer
cd-dvd
profiles
system
boot
systemd
tests
+2 -1
nixos/modules/installer/cd-dvd/channel.nix
···
echo "unpacking the NixOS/Nixpkgs sources..."
mkdir -p /nix/var/nix/profiles/per-user/root
${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/per-user/root/channels \
-
-i ${channelSources} --quiet --option build-use-substitutes false
mkdir -m 0700 -p /root/.nix-defexpr
ln -s /nix/var/nix/profiles/per-user/root/channels /root/.nix-defexpr/channels
mkdir -m 0755 -p /var/lib/nixos
···
echo "unpacking the NixOS/Nixpkgs sources..."
mkdir -p /nix/var/nix/profiles/per-user/root
${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/per-user/root/channels \
+
-i ${channelSources} --quiet --option build-use-substitutes false \
+
${optionalString config.boot.initrd.systemd.enable "--option sandbox false"} # There's an issue with pivot_root
mkdir -m 0700 -p /root/.nix-defexpr
ln -s /nix/var/nix/profiles/per-user/root/channels /root/.nix-defexpr/channels
mkdir -m 0755 -p /var/lib/nixos
+4
nixos/modules/profiles/installation-device.nix
···
stdenvNoCC # for runCommand
busybox
jq # for closureInfo
];
# Show all debug messages from the kernel but don't log refused packets
···
stdenvNoCC # for runCommand
busybox
jq # for closureInfo
+
# For boot.initrd.systemd
+
makeInitrdNGTool
+
systemdStage1
+
systemdStage1Network
];
# Show all debug messages from the kernel but don't log refused packets
+15
nixos/modules/system/boot/systemd/initrd.nix
···
''systemctl --no-block switch-root /sysroot "''${NEW_INIT}"''
];
};
};
boot.kernelParams = lib.mkIf (config.boot.resumeDevice != "") [ "resume=${config.boot.resumeDevice}" ];
···
''systemctl --no-block switch-root /sysroot "''${NEW_INIT}"''
];
};
+
+
services.panic-on-fail = {
+
wantedBy = ["emergency.target"];
+
unitConfig = {
+
DefaultDependencies = false;
+
ConditionKernelCommandLine = [
+
"|boot.panic_on_fail"
+
"|stage1panic"
+
];
+
};
+
script = ''
+
echo c > /proc/sysrq-trigger
+
'';
+
serviceConfig.Type = "oneshot";
+
};
};
boot.kernelParams = lib.mkIf (config.boot.resumeDevice != "") [ "resume=${config.boot.resumeDevice}" ];
+1
nixos/tests/all-tests.nix
···
input-remapper = handleTest ./input-remapper.nix {};
inspircd = handleTest ./inspircd.nix {};
installer = handleTest ./installer.nix {};
invoiceplane = handleTest ./invoiceplane.nix {};
iodine = handleTest ./iodine.nix {};
ipfs = handleTest ./ipfs.nix {};
···
input-remapper = handleTest ./input-remapper.nix {};
inspircd = handleTest ./inspircd.nix {};
installer = handleTest ./installer.nix {};
+
installer-systemd-stage-1 = handleTest ./installer-systemd-stage-1.nix {};
invoiceplane = handleTest ./invoiceplane.nix {};
iodine = handleTest ./iodine.nix {};
ipfs = handleTest ./ipfs.nix {};
+33
nixos/tests/installer-systemd-stage-1.nix
···
···
+
{ system ? builtins.currentSystem
+
, config ? {}
+
, pkgs ? import ../.. { inherit system config; }
+
}:
+
+
{
+
# Some of these tests don't work with systemd stage 1 yet. Uncomment
+
# them when fixed.
+
inherit (import ./installer.nix { inherit system config pkgs; systemdStage1 = true; })
+
# bcache
+
# btrfsSimple
+
# btrfsSubvolDefault
+
# btrfsSubvols
+
# encryptedFSWithKeyfile
+
# grub1
+
# luksroot
+
# luksroot-format1
+
# luksroot-format2
+
# lvm
+
separateBoot
+
separateBootFat
+
simple
+
simpleLabels
+
simpleProvided
+
simpleSpecialised
+
simpleUefiGrub
+
simpleUefiGrubSpecialisation
+
simpleUefiSystemdBoot
+
# swraid
+
# zfsroot
+
;
+
+
}
+6 -1
nixos/tests/installer.nix
···
{ system ? builtins.currentSystem,
config ? {},
-
pkgs ? import ../.. { inherit system config; }
}:
with import ../lib/testing-python.nix { inherit system pkgs; };
···
# To ensure that we can rebuild the grub configuration on the nixos-rebuild
system.extraDependencies = with pkgs; [ stdenvNoCC ];
${optionalString (bootLoader == "grub") ''
boot.loader.grub.version = ${toString grubVersion};
···
virtualisation.diskSize = 8 * 1024;
virtualisation.cores = 8;
virtualisation.memorySize = 1536;
# Use a small /dev/vdb as the root disk for the
# installer. This ensures the target disk (/dev/vda) is
···
{ system ? builtins.currentSystem,
config ? {},
+
pkgs ? import ../.. { inherit system config; },
+
systemdStage1 ? false
}:
with import ../lib/testing-python.nix { inherit system pkgs; };
···
# To ensure that we can rebuild the grub configuration on the nixos-rebuild
system.extraDependencies = with pkgs; [ stdenvNoCC ];
+
+
${optionalString systemdStage1 "boot.initrd.systemd.enable = true;"}
${optionalString (bootLoader == "grub") ''
boot.loader.grub.version = ${toString grubVersion};
···
virtualisation.diskSize = 8 * 1024;
virtualisation.cores = 8;
virtualisation.memorySize = 1536;
+
+
boot.initrd.systemd.enable = systemdStage1;
# Use a small /dev/vdb as the root disk for the
# installer. This ensures the target disk (/dev/vda) is