mirror of
https://github.com/nix-community/disko.git
synced 2026-12-02 14: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": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1773628058,
|
"lastModified": 1778036283,
|
||||||
"narHash": "sha256-hpXH0z3K9xv0fHaje136KY872VT2T5uwxtezlAskQgY=",
|
"narHash": "sha256-62EWg6lI0qyzm7oAx5cAnGkLutvJsRBe0KkEW2JDZCE=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "f8573b9c935cfaa162dd62cc9e75ae2db86f85df",
|
"rev": "ed67bc86e84e51d4a88e73c7fd36006dc876476f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
+8
-2
@@ -142,6 +142,9 @@ let
|
|||||||
boot.initrd.preDeviceCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
|
boot.initrd.preDeviceCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
|
||||||
echo -n 'secretsecret' > /tmp/secret.key
|
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.consoleLogLevel = lib.mkForce 100;
|
||||||
boot.loader.systemd-boot.enable = lib.mkDefault efi;
|
boot.loader.systemd-boot.enable = lib.mkDefault efi;
|
||||||
};
|
};
|
||||||
@@ -187,7 +190,10 @@ let
|
|||||||
"cache=loose"
|
"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
|
# Silence mdadm warning about missing MAILADDR or PROGRAM
|
||||||
boot.swraid.mdadmConf = "PROGRAM ${pkgs.coreutils}/bin/true";
|
boot.swraid.mdadmConf = "PROGRAM ${pkgs.coreutils}/bin/true";
|
||||||
@@ -342,7 +348,7 @@ let
|
|||||||
]
|
]
|
||||||
''}
|
''}
|
||||||
machine = create_machine(start_command=" ".join(start_command), **kwargs)
|
machine = create_machine(start_command=" ".join(start_command), **kwargs)
|
||||||
driver.machines.append(machine)
|
driver.machines_qemu.append(machine)
|
||||||
return machine
|
return machine
|
||||||
|
|
||||||
machine.start()
|
machine.start()
|
||||||
|
|||||||
@@ -191,9 +191,11 @@
|
|||||||
(
|
(
|
||||||
TEMPDIR="$(mktemp -d)";
|
TEMPDIR="$(mktemp -d)";
|
||||||
MNTPOINT="$(mktemp -d)";
|
MNTPOINT="$(mktemp -d)";
|
||||||
${lib.optionalString (
|
${lib.optionalString (config.passwordFile != null) ''
|
||||||
config.passwordFile != null
|
if ! bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}"; then
|
||||||
) ''bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}";''}
|
test -d "/sys/fs/bcachefs/${config.uuid}";
|
||||||
|
fi;
|
||||||
|
''}
|
||||||
mount \
|
mount \
|
||||||
-t bcachefs \
|
-t bcachefs \
|
||||||
-o "${lib.concatStringsSep "," (lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions))}" \
|
-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,
|
# @todo Figure out why the "X-mount.mkdir" option here doesn't seem to work,
|
||||||
# necessitating running `mkdir` here.
|
# necessitating running `mkdir` here.
|
||||||
mkdir -p "${rootMountPoint}${subvolume.mountpoint}";
|
mkdir -p "${rootMountPoint}${subvolume.mountpoint}";
|
||||||
${lib.optionalString (
|
${lib.optionalString (config.passwordFile != null) ''
|
||||||
config.passwordFile != null
|
if ! bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}"; then
|
||||||
) ''bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}";''}
|
test -d "/sys/fs/bcachefs/${config.uuid}";
|
||||||
|
fi;
|
||||||
|
''}
|
||||||
mount \
|
mount \
|
||||||
-t bcachefs \
|
-t bcachefs \
|
||||||
-o "${
|
-o "${
|
||||||
@@ -260,9 +264,11 @@
|
|||||||
# @todo Figure out why the "X-mount.mkdir" option here doesn't seem to work,
|
# @todo Figure out why the "X-mount.mkdir" option here doesn't seem to work,
|
||||||
# necessitating running `mkdir` here.
|
# necessitating running `mkdir` here.
|
||||||
mkdir -p "${rootMountPoint}${config.mountpoint}";
|
mkdir -p "${rootMountPoint}${config.mountpoint}";
|
||||||
${lib.optionalString (
|
${lib.optionalString (config.passwordFile != null) ''
|
||||||
config.passwordFile != null
|
if ! bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}"; then
|
||||||
) ''bcachefs unlock -k session "/dev/disk/by-uuid/${config.uuid}" < "${config.passwordFile}";''}
|
test -d "/sys/fs/bcachefs/${config.uuid}";
|
||||||
|
fi;
|
||||||
|
''}
|
||||||
mount \
|
mount \
|
||||||
-t bcachefs \
|
-t bcachefs \
|
||||||
-o "${lib.concatStringsSep "," (lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions))}" \
|
-o "${lib.concatStringsSep "," (lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions))}" \
|
||||||
|
|||||||
+37
-25
@@ -25,12 +25,6 @@ diskoLib.testLib.makeDiskoTest {
|
|||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
pkgs.jq
|
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 = ''
|
extraTestScript = ''
|
||||||
# Print debug information.
|
# Print debug information.
|
||||||
@@ -39,13 +33,23 @@ diskoLib.testLib.makeDiskoTest {
|
|||||||
machine.succeed("lsblk >&2");
|
machine.succeed("lsblk >&2");
|
||||||
machine.succeed("lsblk -f >&2");
|
machine.succeed("lsblk -f >&2");
|
||||||
machine.succeed("mount >&2");
|
machine.succeed("mount >&2");
|
||||||
# We need to manually unlock /dev/vda2 for some reason
|
machine.succeed("ls /sys/fs/bcachefs/ >&2");
|
||||||
# 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("findmnt --json >&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.
|
# Verify existence of mountpoints.
|
||||||
machine.succeed("mountpoint /");
|
machine.succeed("mountpoint /");
|
||||||
machine.succeed("mountpoint /home");
|
machine.succeed("mountpoint /home");
|
||||||
@@ -53,21 +57,29 @@ diskoLib.testLib.makeDiskoTest {
|
|||||||
machine.succeed("mountpoint /home/Documents");
|
machine.succeed("mountpoint /home/Documents");
|
||||||
machine.fail("mountpoint /non-existent");
|
machine.fail("mountpoint /non-existent");
|
||||||
|
|
||||||
# Verify device membership and labels.
|
multi_sysfs = bcachefs_sysfs("/")
|
||||||
machine.succeed("bcachefs show-super /dev/vda2 | grep 'Devices:' | grep -q '3'");
|
single_sysfs = bcachefs_sysfs("/home/Documents")
|
||||||
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'");
|
|
||||||
|
|
||||||
# Verify format arguments.
|
# Verify device membership.
|
||||||
# Test that lza4 compression and background_compression options were set for vda2.
|
multi_devs = int(machine.succeed(f"ls -d {multi_sysfs}/dev-* | wc -l").strip())
|
||||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*compression:[[:space:]]+lz4'");
|
assert multi_devs == 3, f"Expected 3 devices in {multi_sysfs}, got {multi_devs}"
|
||||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*background_compression:[[:space:]]+lz4'");
|
single_devs = int(machine.succeed(f"ls -d {single_sysfs}/dev-* | wc -l").strip())
|
||||||
# Test that no compression option was set for vdd1.
|
assert single_devs == 1, f"Expected 1 device in {single_sysfs}, got {single_devs}"
|
||||||
machine.succeed("bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]*compression:[[:space:]]+none'");
|
|
||||||
|
# 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.
|
# Verify mount options from configuration.
|
||||||
# Test that verbose option was set for "/".
|
# Test that verbose option was set for "/".
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ pkgs.testers.nixosTest {
|
|||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
def create_test_machine(
|
def create_test_machine(
|
||||||
oldmachine=None, **kwargs
|
oldmachine, **kwargs
|
||||||
): # taken from <nixpkgs/nixos/tests/installer.nix>
|
): # taken from <nixpkgs/nixos/tests/installer.nix>
|
||||||
start_command = [
|
start_command = [
|
||||||
"${pkgs.qemu_test}/bin/qemu-kvm",
|
"${pkgs.qemu_test}/bin/qemu-kvm",
|
||||||
@@ -48,7 +48,7 @@ pkgs.testers.nixosTest {
|
|||||||
"virtio-blk-pci,drive=drive1",
|
"virtio-blk-pci,drive=drive1",
|
||||||
]
|
]
|
||||||
machine = create_machine(start_command=" ".join(start_command), **kwargs)
|
machine = create_machine(start_command=" ".join(start_command), **kwargs)
|
||||||
driver.machines.append(machine)
|
driver.machines_qemu.append(machine)
|
||||||
return machine
|
return machine
|
||||||
machine.succeed("lsblk >&2")
|
machine.succeed("lsblk >&2")
|
||||||
|
|
||||||
|
|||||||
+51
-42
@@ -9,23 +9,22 @@ diskoLib.testLib.makeDiskoTest {
|
|||||||
extraInstallerConfig.networking.hostId = "8425e349";
|
extraInstallerConfig.networking.hostId = "8425e349";
|
||||||
extraSystemConfig = {
|
extraSystemConfig = {
|
||||||
networking.hostId = "8425e349";
|
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 = ''
|
extraTestScript = ''
|
||||||
|
import json
|
||||||
|
|
||||||
def assert_property(ds, property, expected_value):
|
def assert_property(ds, property, expected_value):
|
||||||
out = machine.succeed(f"zfs get -H {property} {ds} -o value").rstrip()
|
out = machine.succeed(f"zfs get -H {property} {ds} -o value").rstrip()
|
||||||
assert (
|
assert (
|
||||||
out == expected_value
|
out == expected_value
|
||||||
), f"Expected {property}={expected_value} on {ds}, got: {out}"
|
), 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
|
# These fields are 0 if l2arc is disabled
|
||||||
assert (
|
assert (
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
@@ -40,39 +39,49 @@ diskoLib.testLib.makeDiskoTest {
|
|||||||
assert_property("zroot/zfs_fs", "compression", "zstd")
|
assert_property("zroot/zfs_fs", "compression", "zstd")
|
||||||
machine.succeed("mountpoint /zfs_fs");
|
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
|
# `zpool status -j` groups vdevs by class at the pool level: `vdevs` (normal data, wrapped under
|
||||||
# the pool name or a designation like log/cache/spare/dedup/special) and first portion of the vdev name (empty for a
|
# the `zroot` root vdev) plus `dedup`, `special`, `logs`, `l2cache`, `spares`. Each entry in a
|
||||||
# disk from a single vdev, mirror for devices in a mirror. This makes it easy to verify that the layout is as
|
# group is either a leaf (just a device path) or a mirror vdev with nested `vdevs`. Bucket each
|
||||||
# expected.
|
# leaf into (class, in_mirror, canonical path) and diff against the expected layout.
|
||||||
group = ""
|
def collect_leaves(class_name, entries):
|
||||||
vdev = ""
|
out = []
|
||||||
actual = []
|
for name, entry in entries.items():
|
||||||
for line in machine.succeed("zpool status -P zroot").split("\n"):
|
if entry.get("vdev_type") == "mirror":
|
||||||
first_word = line.strip().split(" ", 1)[0]
|
out.extend((class_name, "mirror", canonical_path(child)) for child in entry["vdevs"])
|
||||||
if line.startswith("\t ") and first_word.startswith("/"):
|
else:
|
||||||
actual.append(f"{group}{vdev}{first_word}")
|
out.append((class_name, "single", canonical_path(name)))
|
||||||
elif line.startswith("\t "):
|
return out
|
||||||
vdev = f"{first_word.split('-', 1)[0]} "
|
|
||||||
elif line.startswith("\t"):
|
data = json.loads(machine.succeed("zpool status -P -L -j zroot"))
|
||||||
group = f"{first_word} "
|
pool = next(iter(data["pools"].values()))
|
||||||
vdev = ""
|
actual_leaves = sorted(
|
||||||
actual.sort()
|
collect_leaves("normal", pool["vdevs"]["zroot"]["vdevs"])
|
||||||
expected=sorted([
|
+ collect_leaves("dedup", pool.get("dedup", {}))
|
||||||
'zroot /dev/disk/by-partlabel/disk-data1-zfs',
|
+ collect_leaves("special", pool.get("special", {}))
|
||||||
'zroot mirror /dev/disk/by-partlabel/disk-data2-zfs',
|
+ collect_leaves("log", pool.get("logs", {}))
|
||||||
'zroot mirror /dev/disk/by-partlabel/disk-data3-zfs',
|
+ collect_leaves("l2cache", pool.get("l2cache", {}))
|
||||||
'dedup /dev/disk/by-partlabel/disk-dedup3-zfs',
|
+ collect_leaves("spare", pool.get("spares", {}))
|
||||||
'dedup mirror /dev/disk/by-partlabel/disk-dedup1-zfs',
|
)
|
||||||
'dedup mirror /dev/disk/by-partlabel/disk-dedup2-zfs',
|
expected_leaves = sorted([
|
||||||
'special /dev/disk/by-partlabel/disk-special3-zfs',
|
("normal", "single", by_partlabel("disk-data1-zfs")),
|
||||||
'special mirror /dev/disk/by-partlabel/disk-special1-zfs',
|
("normal", "mirror", by_partlabel("disk-data2-zfs")),
|
||||||
'special mirror /dev/disk/by-partlabel/disk-special2-zfs',
|
("normal", "mirror", by_partlabel("disk-data3-zfs")),
|
||||||
'logs /dev/disk/by-partlabel/disk-log3-zfs',
|
("dedup", "single", by_partlabel("disk-dedup3-zfs")),
|
||||||
'logs mirror /dev/disk/by-partlabel/disk-log1-zfs',
|
("dedup", "mirror", by_partlabel("disk-dedup1-zfs")),
|
||||||
'logs mirror /dev/disk/by-partlabel/disk-log2-zfs',
|
("dedup", "mirror", by_partlabel("disk-dedup2-zfs")),
|
||||||
'cache /dev/disk/by-partlabel/disk-cache-zfs',
|
("special", "single", by_partlabel("disk-special3-zfs")),
|
||||||
'spares /dev/disk/by-partlabel/disk-spare-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