address code review issues
This commit is contained in:
parent
d1411444b6
commit
8aa320b4c2
|
@ -1331,6 +1331,7 @@
|
|||
./system/boot/loader/raspberrypi/raspberrypi.nix
|
||||
./system/boot/loader/systemd-boot/systemd-boot.nix
|
||||
./system/boot/luksroot.nix
|
||||
./system/boot/stratisroot.nix
|
||||
./system/boot/modprobe.nix
|
||||
./system/boot/networkd.nix
|
||||
./system/boot/plymouth.nix
|
||||
|
|
|
@ -5,18 +5,19 @@ in
|
|||
{
|
||||
options.boot.stratis = {
|
||||
rootPoolUuid = lib.mkOption {
|
||||
type = types.uniq types.str;
|
||||
description = lib.mdoc ''
|
||||
type = types.uniq (types.nullOr types.str);
|
||||
description = lib.mdDoc ''
|
||||
UUID of the stratis pool that the root fs is located in
|
||||
'';
|
||||
example = "04c68063-90a5-4235-b9dd-6180098a20d9";
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
config = {
|
||||
config = lib.mkIf (config.boot.stratis.rootPoolUuid != null) {
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.boot.initrd.systemd.enable;
|
||||
message = "stratis root fs requires systemd initrd";
|
||||
message = "stratis root fs requires systemd stage 1";
|
||||
}
|
||||
];
|
||||
boot.initrd = {
|
||||
|
|
|
@ -19,7 +19,6 @@ let
|
|||
{ imports =
|
||||
[ ./hardware-configuration.nix
|
||||
<nixpkgs/nixos/modules/testing/test-instrumentation.nix>
|
||||
./amendments.nix
|
||||
];
|
||||
|
||||
documentation.enable = false;
|
||||
|
@ -73,7 +72,7 @@ let
|
|||
# partitions and filesystems.
|
||||
testScriptFun = { bootLoader, createPartitions, grubVersion, grubDevice, grubUseEfi
|
||||
, grubIdentifier, preBootCommands, postBootCommands, extraConfig
|
||||
, testSpecialisationConfig, amendConfig
|
||||
, testSpecialisationConfig
|
||||
}:
|
||||
let iface = if grubVersion == 1 then "ide" else "virtio";
|
||||
isEfi = bootLoader == "systemd-boot" || (bootLoader == "grub" && grubUseEfi);
|
||||
|
@ -130,9 +129,6 @@ let
|
|||
"/mnt/etc/nixos/configuration.nix",
|
||||
)
|
||||
machine.copy_from_host("${pkgs.writeText "secret" "secret"}", "/mnt/etc/nixos/secret")
|
||||
amendments = '{}'
|
||||
${amendConfig}
|
||||
machine.succeed(f"printf '{amendments}' > /mnt/etc/nixos/amendments.nix")
|
||||
|
||||
with subtest("Perform the installation"):
|
||||
machine.succeed("nixos-install < /dev/null >&2")
|
||||
|
@ -285,7 +281,7 @@ let
|
|||
|
||||
|
||||
makeInstallerTest = name:
|
||||
{ createPartitions, preBootCommands ? "", postBootCommands ? "", extraConfig ? "", amendConfig ? ""
|
||||
{ createPartitions, preBootCommands ? "", postBootCommands ? "", extraConfig ? ""
|
||||
, extraInstallerConfig ? {}
|
||||
, bootLoader ? "grub" # either "grub" or "systemd-boot"
|
||||
, grubVersion ? 2, grubDevice ? "/dev/vda", grubIdentifier ? "uuid", grubUseEfi ? false
|
||||
|
@ -396,7 +392,7 @@ let
|
|||
|
||||
testScript = testScriptFun {
|
||||
inherit bootLoader createPartitions preBootCommands postBootCommands
|
||||
grubVersion grubDevice grubIdentifier grubUseEfi extraConfig amendConfig
|
||||
grubVersion grubDevice grubIdentifier grubUseEfi extraConfig
|
||||
testSpecialisationConfig;
|
||||
};
|
||||
};
|
||||
|
@ -1042,6 +1038,12 @@ in {
|
|||
"mkdir -p /mnt/boot",
|
||||
"mount /dev/vda1 /mnt/boot"
|
||||
)
|
||||
|
||||
(header, pool_line) = machine.succeed("stratis pool list").splitlines()
|
||||
index = header.find("UUID")
|
||||
uuid = pool_line[index - 32: index + 4]
|
||||
machine.succeed("mkdir -p /mnt/etc/nixos")
|
||||
machine.succeed(f"printf %s {uuid} > /mnt/etc/nixos/rootPoolUuid.txt")
|
||||
'';
|
||||
bootLoader = "systemd-boot";
|
||||
extraInstallerConfig = { modulesPath, ...}: {
|
||||
|
@ -1056,19 +1058,6 @@ in {
|
|||
];
|
||||
};
|
||||
};
|
||||
amendConfig = ''
|
||||
# This comment is here for Python indentation purposes
|
||||
(header, pool_line) = machine.succeed("stratis pool list").splitlines()
|
||||
index = header.find("UUID")
|
||||
uuid = pool_line[index - 32: index + 4]
|
||||
amendments = f"""{{ modulesPath, ... }}: {{
|
||||
imports = [
|
||||
(modulesPath + "/system/boot/stratisroot.nix")
|
||||
];
|
||||
config = {{
|
||||
boot.stratis.rootPoolUuid = "{uuid}";
|
||||
}};
|
||||
}}"""
|
||||
'';
|
||||
extraConfig = "boot.stratis.rootPoolUuid = builtins.readFile ./rootPoolUuid.txt;";
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue