Add a test. Broken because unmounts don't work with the squashes?
This commit is contained in:
parent
3a1ad3ad53
commit
6f61d2d19a
20
quickly.nix
20
quickly.nix
@ -3,7 +3,10 @@
|
|||||||
|
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
let
|
||||||
|
inherit (lib) mkOption literalExample;
|
||||||
|
netbootpkgs = pkgs.callPackage ./pkgs {};
|
||||||
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
@ -81,20 +84,20 @@ with lib;
|
|||||||
[ config.system.build.toplevel ];
|
[ config.system.build.toplevel ];
|
||||||
|
|
||||||
# Create the squashfs image that contains the Nix store.
|
# Create the squashfs image that contains the Nix store.
|
||||||
system.build.squashfsStore = pkgs.makeSquashes {
|
system.build.squashfsStore = netbootpkgs.makeSquashfsManifest {
|
||||||
name = "iso-manifeiist";
|
name = "iso-manifeiist";
|
||||||
storeContents = config.netboot.storeContents;
|
storeContents = config.netboot.storeContents;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
# Create the initrd
|
# Create the initrd
|
||||||
system.build.netbootRamdisk = pkgs.makeInitrd {
|
system.build.netbootRamdisk = pkgs.makeInitrd {
|
||||||
inherit (config.boot.initrd) compressor;
|
inherit (config.boot.initrd) compressor;
|
||||||
prepend = [
|
prepend = [
|
||||||
"${config.system.build.initialRamdisk}/initrd"
|
"${config.system.build.initialRamdisk}/initrd"
|
||||||
"${(
|
"${(
|
||||||
pkgs.makeBetterInitrd {
|
netbootpkgs.makeCpioRecursive {
|
||||||
name = "better-initrd";
|
name = "better-initrd";
|
||||||
|
inherit (config.boot.initrd) compressor;
|
||||||
root = config.system.build.squashfsStore;
|
root = config.system.build.squashfsStore;
|
||||||
}
|
}
|
||||||
)}/initrd"
|
)}/initrd"
|
||||||
@ -118,6 +121,15 @@ with lib;
|
|||||||
boot
|
boot
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
system.build.ipxeBootDir = pkgs.symlinkJoin {
|
||||||
|
name = "ipxeBootDir";
|
||||||
|
paths = [
|
||||||
|
config.system.build.netbootRamdisk
|
||||||
|
config.system.build.kernel
|
||||||
|
config.system.build.netbootIpxeScript
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
boot.loader.timeout = 10;
|
boot.loader.timeout = 10;
|
||||||
|
|
||||||
boot.postBootCommands =
|
boot.postBootCommands =
|
||||||
|
|||||||
49
test.nix
Normal file
49
test.nix
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> {}
|
||||||
|
, system ? "x86_64-linux"
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (pkgs.lib) concatStringsSep mapAttrsToList;
|
||||||
|
testlib = import "${pkgs.path}/nixos/lib/testing-python.nix" { inherit system pkgs; };
|
||||||
|
|
||||||
|
pythonDict = params: "\n {\n ${concatStringsSep ",\n " (mapAttrsToList (name: param: "\"${name}\": \"${param}\"") params)},\n }\n";
|
||||||
|
|
||||||
|
makeNetbootTest = name: extraConfig:
|
||||||
|
let
|
||||||
|
config = (
|
||||||
|
import "${pkgs.path}/nixos/lib/eval-config.nix" {
|
||||||
|
inherit system;
|
||||||
|
modules = [
|
||||||
|
./quickly.nix
|
||||||
|
"${pkgs.path}/nixos/modules/testing/test-instrumentation.nix"
|
||||||
|
{ key = "serial"; }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
).config;
|
||||||
|
|
||||||
|
machineConfig = pythonDict (
|
||||||
|
{
|
||||||
|
qemuFlags = "-boot order=n -m 2000";
|
||||||
|
netBackendArgs = "tftp=${config.system.build.ipxeBootDir},bootfile=netboot.ipxe";
|
||||||
|
} // extraConfig
|
||||||
|
);
|
||||||
|
in
|
||||||
|
testlib.makeTest {
|
||||||
|
name = "boot-netboot-" + name;
|
||||||
|
nodes = {};
|
||||||
|
testScript = ''
|
||||||
|
machine = create_machine(${machineConfig})
|
||||||
|
machine.start()
|
||||||
|
machine.wait_for_unit("multi-user.target")
|
||||||
|
machine.shutdown()
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
biosNetboot = makeNetbootTest "bios" {};
|
||||||
|
|
||||||
|
uefiNetboot = makeNetbootTest "uefi" {
|
||||||
|
bios = "${pkgs.OVMF.fd}/FV/OVMF.fd";
|
||||||
|
# Custom ROM is needed for EFI PXE boot. I failed to understand exactly why, because QEMU should still use iPXE for EFI.
|
||||||
|
netFrontendArgs = "romfile=${pkgs.ipxe}/ipxe.efirom";
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user