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/raspberrypi/raspberrypi.nix
|
||||||
./system/boot/loader/systemd-boot/systemd-boot.nix
|
./system/boot/loader/systemd-boot/systemd-boot.nix
|
||||||
./system/boot/luksroot.nix
|
./system/boot/luksroot.nix
|
||||||
|
./system/boot/stratisroot.nix
|
||||||
./system/boot/modprobe.nix
|
./system/boot/modprobe.nix
|
||||||
./system/boot/networkd.nix
|
./system/boot/networkd.nix
|
||||||
./system/boot/plymouth.nix
|
./system/boot/plymouth.nix
|
||||||
|
|
|
@ -5,18 +5,19 @@ in
|
||||||
{
|
{
|
||||||
options.boot.stratis = {
|
options.boot.stratis = {
|
||||||
rootPoolUuid = lib.mkOption {
|
rootPoolUuid = lib.mkOption {
|
||||||
type = types.uniq types.str;
|
type = types.uniq (types.nullOr types.str);
|
||||||
description = lib.mdoc ''
|
description = lib.mdDoc ''
|
||||||
UUID of the stratis pool that the root fs is located in
|
UUID of the stratis pool that the root fs is located in
|
||||||
'';
|
'';
|
||||||
example = "04c68063-90a5-4235-b9dd-6180098a20d9";
|
example = "04c68063-90a5-4235-b9dd-6180098a20d9";
|
||||||
|
default = null;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = lib.mkIf (config.boot.stratis.rootPoolUuid != null) {
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = config.boot.initrd.systemd.enable;
|
assertion = config.boot.initrd.systemd.enable;
|
||||||
message = "stratis root fs requires systemd initrd";
|
message = "stratis root fs requires systemd stage 1";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
boot.initrd = {
|
boot.initrd = {
|
||||||
|
|
|
@ -19,7 +19,6 @@ let
|
||||||
{ imports =
|
{ imports =
|
||||||
[ ./hardware-configuration.nix
|
[ ./hardware-configuration.nix
|
||||||
<nixpkgs/nixos/modules/testing/test-instrumentation.nix>
|
<nixpkgs/nixos/modules/testing/test-instrumentation.nix>
|
||||||
./amendments.nix
|
|
||||||
];
|
];
|
||||||
|
|
||||||
documentation.enable = false;
|
documentation.enable = false;
|
||||||
|
@ -73,7 +72,7 @@ let
|
||||||
# partitions and filesystems.
|
# partitions and filesystems.
|
||||||
testScriptFun = { bootLoader, createPartitions, grubVersion, grubDevice, grubUseEfi
|
testScriptFun = { bootLoader, createPartitions, grubVersion, grubDevice, grubUseEfi
|
||||||
, grubIdentifier, preBootCommands, postBootCommands, extraConfig
|
, grubIdentifier, preBootCommands, postBootCommands, extraConfig
|
||||||
, testSpecialisationConfig, amendConfig
|
, testSpecialisationConfig
|
||||||
}:
|
}:
|
||||||
let iface = if grubVersion == 1 then "ide" else "virtio";
|
let iface = if grubVersion == 1 then "ide" else "virtio";
|
||||||
isEfi = bootLoader == "systemd-boot" || (bootLoader == "grub" && grubUseEfi);
|
isEfi = bootLoader == "systemd-boot" || (bootLoader == "grub" && grubUseEfi);
|
||||||
|
@ -130,9 +129,6 @@ let
|
||||||
"/mnt/etc/nixos/configuration.nix",
|
"/mnt/etc/nixos/configuration.nix",
|
||||||
)
|
)
|
||||||
machine.copy_from_host("${pkgs.writeText "secret" "secret"}", "/mnt/etc/nixos/secret")
|
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"):
|
with subtest("Perform the installation"):
|
||||||
machine.succeed("nixos-install < /dev/null >&2")
|
machine.succeed("nixos-install < /dev/null >&2")
|
||||||
|
@ -285,7 +281,7 @@ let
|
||||||
|
|
||||||
|
|
||||||
makeInstallerTest = name:
|
makeInstallerTest = name:
|
||||||
{ createPartitions, preBootCommands ? "", postBootCommands ? "", extraConfig ? "", amendConfig ? ""
|
{ createPartitions, preBootCommands ? "", postBootCommands ? "", extraConfig ? ""
|
||||||
, extraInstallerConfig ? {}
|
, extraInstallerConfig ? {}
|
||||||
, bootLoader ? "grub" # either "grub" or "systemd-boot"
|
, bootLoader ? "grub" # either "grub" or "systemd-boot"
|
||||||
, grubVersion ? 2, grubDevice ? "/dev/vda", grubIdentifier ? "uuid", grubUseEfi ? false
|
, grubVersion ? 2, grubDevice ? "/dev/vda", grubIdentifier ? "uuid", grubUseEfi ? false
|
||||||
|
@ -396,7 +392,7 @@ let
|
||||||
|
|
||||||
testScript = testScriptFun {
|
testScript = testScriptFun {
|
||||||
inherit bootLoader createPartitions preBootCommands postBootCommands
|
inherit bootLoader createPartitions preBootCommands postBootCommands
|
||||||
grubVersion grubDevice grubIdentifier grubUseEfi extraConfig amendConfig
|
grubVersion grubDevice grubIdentifier grubUseEfi extraConfig
|
||||||
testSpecialisationConfig;
|
testSpecialisationConfig;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1025,23 +1021,29 @@ in {
|
||||||
stratisRoot = makeInstallerTest "stratisRoot" {
|
stratisRoot = makeInstallerTest "stratisRoot" {
|
||||||
createPartitions = ''
|
createPartitions = ''
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
"sgdisk --zap-all /dev/vda",
|
"sgdisk --zap-all /dev/vda",
|
||||||
"sgdisk --new=1:0:+100M --typecode=0:ef00 /dev/vda", # /boot
|
"sgdisk --new=1:0:+100M --typecode=0:ef00 /dev/vda", # /boot
|
||||||
"sgdisk --new=2:0:+1G --typecode=0:8200 /dev/vda", # swap
|
"sgdisk --new=2:0:+1G --typecode=0:8200 /dev/vda", # swap
|
||||||
"sgdisk --new=3:0:+5G --typecode=0:8300 /dev/vda", # /
|
"sgdisk --new=3:0:+5G --typecode=0:8300 /dev/vda", # /
|
||||||
"udevadm settle",
|
"udevadm settle",
|
||||||
|
|
||||||
"mkfs.vfat /dev/vda1",
|
"mkfs.vfat /dev/vda1",
|
||||||
"mkswap /dev/vda2 -L swap",
|
"mkswap /dev/vda2 -L swap",
|
||||||
"swapon -L swap",
|
"swapon -L swap",
|
||||||
"stratis pool create my-pool /dev/vda3",
|
"stratis pool create my-pool /dev/vda3",
|
||||||
"stratis filesystem create my-pool nixos",
|
"stratis filesystem create my-pool nixos",
|
||||||
"udevadm settle",
|
"udevadm settle",
|
||||||
|
|
||||||
"mount /dev/stratis/my-pool/nixos /mnt",
|
"mount /dev/stratis/my-pool/nixos /mnt",
|
||||||
"mkdir -p /mnt/boot",
|
"mkdir -p /mnt/boot",
|
||||||
"mount /dev/vda1 /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";
|
bootLoader = "systemd-boot";
|
||||||
extraInstallerConfig = { modulesPath, ...}: {
|
extraInstallerConfig = { modulesPath, ...}: {
|
||||||
|
@ -1056,19 +1058,6 @@ in {
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
amendConfig = ''
|
extraConfig = "boot.stratis.rootPoolUuid = builtins.readFile ./rootPoolUuid.txt;";
|
||||||
# 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}";
|
|
||||||
}};
|
|
||||||
}}"""
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue