mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 13:03:28 +01:00
flake: bump nixpkgs (#1258)
This commit is contained in:
6 files changed
+116
-83
No files matched your search
Generated
+3
-3
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1773628058,
|
||||
"narHash": "sha256-hpXH0z3K9xv0fHaje136KY872VT2T5uwxtezlAskQgY=",
|
||||
"lastModified": 1778036283,
|
||||
"narHash": "sha256-62EWg6lI0qyzm7oAx5cAnGkLutvJsRBe0KkEW2JDZCE=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f8573b9c935cfaa162dd62cc9e75ae2db86f85df",
|
||||
"rev": "ed67bc86e84e51d4a88e73c7fd36006dc876476f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
+8
-2
@@ -142,6 +142,9 @@ let
|
||||
boot.initrd.preDeviceCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
|
||||
echo -n 'secretsecret' > /tmp/secret.key
|
||||
'';
|
||||
boot.initrd.secrets = lib.mkIf config.boot.initrd.systemd.enable {
|
||||
"/tmp/secret.key" = pkgs.writeText "secret.key" "secretsecret";
|
||||
};
|
||||
boot.consoleLogLevel = lib.mkForce 100;
|
||||
boot.loader.systemd-boot.enable = lib.mkDefault efi;
|
||||
};
|
||||
@@ -187,7 +190,10 @@ let
|
||||
"cache=loose"
|
||||
];
|
||||
};
|
||||
boot.zfs.devNodes = "/dev/disk/by-uuid"; # needed because /dev/disk/by-id is empty in qemu-vms
|
||||
# /dev/disk-by-id is empty in QEMU VMs, /dev/disk/by-uuid only shows one entry
|
||||
# per ZFS pool as members use the pool's GUID, /dev/disk/by-partuuid only shows
|
||||
# partitions so LVM backed members are missed. /dev is the only thing that catches all.
|
||||
boot.zfs.devNodes = "/dev";
|
||||
|
||||
# Silence mdadm warning about missing MAILADDR or PROGRAM
|
||||
boot.swraid.mdadmConf = "PROGRAM ${pkgs.coreutils}/bin/true";
|
||||
@@ -342,7 +348,7 @@ let
|
||||
]
|
||||
''}
|
||||
machine = create_machine(start_command=" ".join(start_command), **kwargs)
|
||||
driver.machines.append(machine)
|
||||
driver.machines_qemu.append(machine)
|
||||
return machine
|
||||
|
||||
machine.start()
|
||||
|
||||
@@ -191,9 +191,11 @@
|
||||
(
|
||||
TEMPDIR="$(mktemp -d)";
|
||||
MNTPOINT="$(mktemp -d)";
|
||||
${lib.optionalString (
|
||||
config.passwordFile != null
|
||||
) ''bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}";''}
|
||||
${lib.optionalString (config.passwordFile != null) ''
|
||||
if ! bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}"; then
|
||||
test -d "/sys/fs/bcachefs/${config.uuid}";
|
||||
fi;
|
||||
''}
|
||||
mount \
|
||||
-t bcachefs \
|
||||
-o "${lib.concatStringsSep "," (lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions))}" \
|
||||
@@ -228,9 +230,11 @@
|
||||
# @todo Figure out why the "X-mount.mkdir" option here doesn't seem to work,
|
||||
# necessitating running `mkdir` here.
|
||||
mkdir -p "${rootMountPoint}${subvolume.mountpoint}";
|
||||
${lib.optionalString (
|
||||
config.passwordFile != null
|
||||
) ''bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}";''}
|
||||
${lib.optionalString (config.passwordFile != null) ''
|
||||
if ! bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}"; then
|
||||
test -d "/sys/fs/bcachefs/${config.uuid}";
|
||||
fi;
|
||||
''}
|
||||
mount \
|
||||
-t bcachefs \
|
||||
-o "${
|
||||
@@ -260,9 +264,11 @@
|
||||
# @todo Figure out why the "X-mount.mkdir" option here doesn't seem to work,
|
||||
# necessitating running `mkdir` here.
|
||||
mkdir -p "${rootMountPoint}${config.mountpoint}";
|
||||
${lib.optionalString (
|
||||
config.passwordFile != null
|
||||
) ''bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}";''}
|
||||
${lib.optionalString (config.passwordFile != null) ''
|
||||
if ! bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}"; then
|
||||
test -d "/sys/fs/bcachefs/${config.uuid}";
|
||||
fi;
|
||||
''}
|
||||
mount \
|
||||
-t bcachefs \
|
||||
-o "${lib.concatStringsSep "," (lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions))}" \
|
||||
|
||||
+37
-25
@@ -25,12 +25,6 @@ diskoLib.testLib.makeDiskoTest {
|
||||
environment.systemPackages = [
|
||||
pkgs.jq
|
||||
];
|
||||
boot.initrd.extraUtilsCommands = ''
|
||||
# Copy tools for bcachefs
|
||||
copy_bin_and_libs ${pkgs.lib.getOutput "mount" pkgs.util-linux}/bin/mount
|
||||
copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/bcachefs
|
||||
copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/mount.bcachefs
|
||||
'';
|
||||
};
|
||||
extraTestScript = ''
|
||||
# Print debug information.
|
||||
@@ -39,13 +33,23 @@ diskoLib.testLib.makeDiskoTest {
|
||||
machine.succeed("lsblk >&2");
|
||||
machine.succeed("lsblk -f >&2");
|
||||
machine.succeed("mount >&2");
|
||||
# We need to manually unlock /dev/vda2 for some reason
|
||||
# even though it should already get unlocked by bootCommands
|
||||
machine.succeed(r'printf "secretsecret" | bcachefs unlock -k session /dev/vda2 >&2');
|
||||
machine.succeed("bcachefs show-super /dev/vda2 >&2");
|
||||
machine.succeed("bcachefs show-super /dev/vdd1 >&2");
|
||||
machine.succeed("ls /sys/fs/bcachefs/ >&2");
|
||||
machine.succeed("findmnt --json >&2");
|
||||
|
||||
# bcachefs-tools >= 1.33.1 cannot read the superblock from a mounted device
|
||||
def bcachefs_sysfs(mp):
|
||||
src = machine.succeed(f"findmnt -no SOURCE {mp}").strip().split(":")[0]
|
||||
dev = src.rsplit("/", 1)[-1]
|
||||
path = machine.succeed(
|
||||
"for d in /sys/fs/bcachefs/*/dev-*/block; do "
|
||||
f' if [ "$(basename "$(readlink -f "$d")")" = "{dev}" ]; then '
|
||||
' dirname "$(dirname "$d")"; break; '
|
||||
" fi; "
|
||||
"done"
|
||||
).strip()
|
||||
assert path, f"no bcachefs sysfs entry found for {mp} (device {dev})"
|
||||
return path
|
||||
|
||||
# Verify existence of mountpoints.
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("mountpoint /home");
|
||||
@@ -53,21 +57,29 @@ diskoLib.testLib.makeDiskoTest {
|
||||
machine.succeed("mountpoint /home/Documents");
|
||||
machine.fail("mountpoint /non-existent");
|
||||
|
||||
# Verify device membership and labels.
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep 'Devices:' | grep -q '3'");
|
||||
machine.succeed("bcachefs show-super /dev/vdd1 | grep 'Devices:' | grep -q '1'");
|
||||
machine.succeed(r"bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdb2'");
|
||||
machine.succeed(r"bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdc1'");
|
||||
machine.succeed(r"bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_b\.vdd1'");
|
||||
machine.succeed(r"bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vde1'");
|
||||
machine.fail("bcachefs show-super /dev/vda2 | grep 'Label:' | grep -q 'non-existent'");
|
||||
multi_sysfs = bcachefs_sysfs("/")
|
||||
single_sysfs = bcachefs_sysfs("/home/Documents")
|
||||
|
||||
# Verify format arguments.
|
||||
# Test that lza4 compression and background_compression options were set for vda2.
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*compression:[[:space:]]+lz4'");
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*background_compression:[[:space:]]+lz4'");
|
||||
# Test that no compression option was set for vdd1.
|
||||
machine.succeed("bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]*compression:[[:space:]]+none'");
|
||||
# Verify device membership.
|
||||
multi_devs = int(machine.succeed(f"ls -d {multi_sysfs}/dev-* | wc -l").strip())
|
||||
assert multi_devs == 3, f"Expected 3 devices in {multi_sysfs}, got {multi_devs}"
|
||||
single_devs = int(machine.succeed(f"ls -d {single_sysfs}/dev-* | wc -l").strip())
|
||||
assert single_devs == 1, f"Expected 1 device in {single_sysfs}, got {single_devs}"
|
||||
|
||||
# Verify labels.
|
||||
multi_labels = set(machine.succeed(f"cat {multi_sysfs}/dev-*/label").split())
|
||||
expected_multi = {"group_a.vdb2", "group_a.vdc1", "group_b.vdd1"}
|
||||
assert multi_labels == expected_multi, f"Expected {expected_multi}, got {multi_labels}"
|
||||
single_labels = set(machine.succeed(f"cat {single_sysfs}/dev-*/label").split())
|
||||
assert single_labels == {"group_a.vde1"}, f"Expected {{'group_a.vde1'}}, got {single_labels}"
|
||||
|
||||
# Verify format arguments via sysfs options.
|
||||
multi_comp = machine.succeed(f"cat {multi_sysfs}/options/compression").strip()
|
||||
assert multi_comp == "lz4", f"Expected lz4 compression, got {multi_comp!r}"
|
||||
multi_bg = machine.succeed(f"cat {multi_sysfs}/options/background_compression").strip()
|
||||
assert multi_bg == "lz4", f"Expected lz4 background_compression, got {multi_bg!r}"
|
||||
single_comp = machine.succeed(f"cat {single_sysfs}/options/compression").strip()
|
||||
assert single_comp == "none", f"Expected no compression, got {single_comp!r}"
|
||||
|
||||
# Verify mount options from configuration.
|
||||
# Test that verbose option was set for "/".
|
||||
|
||||
@@ -32,7 +32,7 @@ pkgs.testers.nixosTest {
|
||||
|
||||
testScript = ''
|
||||
def create_test_machine(
|
||||
oldmachine=None, **kwargs
|
||||
oldmachine, **kwargs
|
||||
): # taken from <nixpkgs/nixos/tests/installer.nix>
|
||||
start_command = [
|
||||
"${pkgs.qemu_test}/bin/qemu-kvm",
|
||||
@@ -48,7 +48,7 @@ pkgs.testers.nixosTest {
|
||||
"virtio-blk-pci,drive=drive1",
|
||||
]
|
||||
machine = create_machine(start_command=" ".join(start_command), **kwargs)
|
||||
driver.machines.append(machine)
|
||||
driver.machines_qemu.append(machine)
|
||||
return machine
|
||||
machine.succeed("lsblk >&2")
|
||||
|
||||
|
||||
+51
-42
@@ -9,23 +9,22 @@ diskoLib.testLib.makeDiskoTest {
|
||||
extraInstallerConfig.networking.hostId = "8425e349";
|
||||
extraSystemConfig = {
|
||||
networking.hostId = "8425e349";
|
||||
# It looks like the 60s of NixOS is sometimes not enough for our virtio-based zpool.
|
||||
# This fixes the flakeiness of the test.
|
||||
boot.initrd.postResumeCommands = ''
|
||||
for i in $(seq 1 120); do
|
||||
if zpool list | grep -q zroot || zpool import -N zroot; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
'';
|
||||
};
|
||||
extraTestScript = ''
|
||||
import json
|
||||
|
||||
def assert_property(ds, property, expected_value):
|
||||
out = machine.succeed(f"zfs get -H {property} {ds} -o value").rstrip()
|
||||
assert (
|
||||
out == expected_value
|
||||
), f"Expected {property}={expected_value} on {ds}, got: {out}"
|
||||
|
||||
def canonical_path(path):
|
||||
return machine.succeed(f"readlink -f {shlex.quote(path)}").strip()
|
||||
|
||||
def by_partlabel(label):
|
||||
return canonical_path(f"/dev/disk/by-partlabel/{label}")
|
||||
|
||||
# These fields are 0 if l2arc is disabled
|
||||
assert (
|
||||
machine.succeed(
|
||||
@@ -40,39 +39,49 @@ diskoLib.testLib.makeDiskoTest {
|
||||
assert_property("zroot/zfs_fs", "compression", "zstd")
|
||||
machine.succeed("mountpoint /zfs_fs");
|
||||
|
||||
# Take the status output and flatten it so that each device is on a single line prefixed with with the group (either
|
||||
# the pool name or a designation like log/cache/spare/dedup/special) and first portion of the vdev name (empty for a
|
||||
# disk from a single vdev, mirror for devices in a mirror. This makes it easy to verify that the layout is as
|
||||
# expected.
|
||||
group = ""
|
||||
vdev = ""
|
||||
actual = []
|
||||
for line in machine.succeed("zpool status -P zroot").split("\n"):
|
||||
first_word = line.strip().split(" ", 1)[0]
|
||||
if line.startswith("\t ") and first_word.startswith("/"):
|
||||
actual.append(f"{group}{vdev}{first_word}")
|
||||
elif line.startswith("\t "):
|
||||
vdev = f"{first_word.split('-', 1)[0]} "
|
||||
elif line.startswith("\t"):
|
||||
group = f"{first_word} "
|
||||
vdev = ""
|
||||
actual.sort()
|
||||
expected=sorted([
|
||||
'zroot /dev/disk/by-partlabel/disk-data1-zfs',
|
||||
'zroot mirror /dev/disk/by-partlabel/disk-data2-zfs',
|
||||
'zroot mirror /dev/disk/by-partlabel/disk-data3-zfs',
|
||||
'dedup /dev/disk/by-partlabel/disk-dedup3-zfs',
|
||||
'dedup mirror /dev/disk/by-partlabel/disk-dedup1-zfs',
|
||||
'dedup mirror /dev/disk/by-partlabel/disk-dedup2-zfs',
|
||||
'special /dev/disk/by-partlabel/disk-special3-zfs',
|
||||
'special mirror /dev/disk/by-partlabel/disk-special1-zfs',
|
||||
'special mirror /dev/disk/by-partlabel/disk-special2-zfs',
|
||||
'logs /dev/disk/by-partlabel/disk-log3-zfs',
|
||||
'logs mirror /dev/disk/by-partlabel/disk-log1-zfs',
|
||||
'logs mirror /dev/disk/by-partlabel/disk-log2-zfs',
|
||||
'cache /dev/disk/by-partlabel/disk-cache-zfs',
|
||||
'spares /dev/disk/by-partlabel/disk-spare-zfs',
|
||||
# `zpool status -j` groups vdevs by class at the pool level: `vdevs` (normal data, wrapped under
|
||||
# the `zroot` root vdev) plus `dedup`, `special`, `logs`, `l2cache`, `spares`. Each entry in a
|
||||
# group is either a leaf (just a device path) or a mirror vdev with nested `vdevs`. Bucket each
|
||||
# leaf into (class, in_mirror, canonical path) and diff against the expected layout.
|
||||
def collect_leaves(class_name, entries):
|
||||
out = []
|
||||
for name, entry in entries.items():
|
||||
if entry.get("vdev_type") == "mirror":
|
||||
out.extend((class_name, "mirror", canonical_path(child)) for child in entry["vdevs"])
|
||||
else:
|
||||
out.append((class_name, "single", canonical_path(name)))
|
||||
return out
|
||||
|
||||
data = json.loads(machine.succeed("zpool status -P -L -j zroot"))
|
||||
pool = next(iter(data["pools"].values()))
|
||||
actual_leaves = sorted(
|
||||
collect_leaves("normal", pool["vdevs"]["zroot"]["vdevs"])
|
||||
+ collect_leaves("dedup", pool.get("dedup", {}))
|
||||
+ collect_leaves("special", pool.get("special", {}))
|
||||
+ collect_leaves("log", pool.get("logs", {}))
|
||||
+ collect_leaves("l2cache", pool.get("l2cache", {}))
|
||||
+ collect_leaves("spare", pool.get("spares", {}))
|
||||
)
|
||||
expected_leaves = sorted([
|
||||
("normal", "single", by_partlabel("disk-data1-zfs")),
|
||||
("normal", "mirror", by_partlabel("disk-data2-zfs")),
|
||||
("normal", "mirror", by_partlabel("disk-data3-zfs")),
|
||||
("dedup", "single", by_partlabel("disk-dedup3-zfs")),
|
||||
("dedup", "mirror", by_partlabel("disk-dedup1-zfs")),
|
||||
("dedup", "mirror", by_partlabel("disk-dedup2-zfs")),
|
||||
("special", "single", by_partlabel("disk-special3-zfs")),
|
||||
("special", "mirror", by_partlabel("disk-special1-zfs")),
|
||||
("special", "mirror", by_partlabel("disk-special2-zfs")),
|
||||
("log", "single", by_partlabel("disk-log3-zfs")),
|
||||
("log", "mirror", by_partlabel("disk-log1-zfs")),
|
||||
("log", "mirror", by_partlabel("disk-log2-zfs")),
|
||||
("l2cache", "single", by_partlabel("disk-cache-zfs")),
|
||||
("spare", "single", by_partlabel("disk-spare-zfs")),
|
||||
])
|
||||
assert actual == expected, f"Incorrect pool layout. Expected:\n\t{'\n\t'.join(expected)}\nActual:\n\t{'\n\t'.join(actual)}"
|
||||
assert actual_leaves == expected_leaves, (
|
||||
"Incorrect pool layout."
|
||||
f"\nExpected: {json.dumps(expected_leaves, indent=2)}"
|
||||
f"\nActual: {json.dumps(actual_leaves, indent=2)}"
|
||||
)
|
||||
'';
|
||||
}
|
||||
Reference in new issue
Block a user