nixos/sanoid: fix aliased options

Fixes https://github.com/NixOS/nixpkgs/issues/181561
This commit is contained in:
Julien Moutinho 2022-08-22 18:53:35 +02:00
parent 5c91de512d
commit 9a94509089
2 changed files with 14 additions and 2 deletions

View File

@ -130,8 +130,8 @@ in
type = types.attrsOf (types.submodule ({ config, options, ... }: { type = types.attrsOf (types.submodule ({ config, options, ... }: {
freeformType = datasetSettingsType; freeformType = datasetSettingsType;
options = commonOptions // datasetOptions; options = commonOptions // datasetOptions;
config.use_template = mkAliasDefinitions (mkDefault options.useTemplate or { }); config.use_template = modules.mkAliasAndWrapDefsWithPriority id (options.useTemplate or { });
config.process_children_only = mkAliasDefinitions (mkDefault options.processChildrenOnly or { }); config.process_children_only = modules.mkAliasAndWrapDefsWithPriority id (options.processChildrenOnly or { });
})); }));
default = { }; default = { };
description = lib.mdDoc "Datasets to snapshot."; description = lib.mdDoc "Datasets to snapshot.";

View File

@ -34,6 +34,7 @@ in {
autosnap = true; autosnap = true;
}; };
datasets."pool/sanoid".use_template = [ "test" ]; datasets."pool/sanoid".use_template = [ "test" ];
datasets."pool/compat".useTemplate = [ "test" ];
extraArgs = [ "--verbose" ]; extraArgs = [ "--verbose" ];
}; };
@ -51,6 +52,12 @@ in {
# Test pool without parent (regression test for https://github.com/NixOS/nixpkgs/pull/180111) # Test pool without parent (regression test for https://github.com/NixOS/nixpkgs/pull/180111)
"pool".target = "root@target:pool/full-pool"; "pool".target = "root@target:pool/full-pool";
# Test backward compatible options (regression test for https://github.com/NixOS/nixpkgs/issues/181561)
"pool/compat" = {
target = "root@target:pool/compat";
extraArgs = [ "--no-sync-snap" ];
};
}; };
}; };
}; };
@ -70,6 +77,7 @@ in {
"udevadm settle", "udevadm settle",
"zpool create pool -R /mnt /dev/vdb1", "zpool create pool -R /mnt /dev/vdb1",
"zfs create pool/sanoid", "zfs create pool/sanoid",
"zfs create pool/compat",
"zfs create pool/syncoid", "zfs create pool/syncoid",
"udevadm settle", "udevadm settle",
) )
@ -94,6 +102,7 @@ in {
# Take snapshot with sanoid # Take snapshot with sanoid
source.succeed("touch /mnt/pool/sanoid/test.txt") source.succeed("touch /mnt/pool/sanoid/test.txt")
source.succeed("touch /mnt/pool/compat/test.txt")
source.systemctl("start --wait sanoid.service") source.systemctl("start --wait sanoid.service")
assert len(source.succeed("zfs allow pool")) == 0, "Pool shouldn't have delegated permissions set after snapshotting" assert len(source.succeed("zfs allow pool")) == 0, "Pool shouldn't have delegated permissions set after snapshotting"
@ -111,6 +120,9 @@ in {
source.systemctl("start --wait syncoid-pool.service") source.systemctl("start --wait syncoid-pool.service")
target.succeed("[[ -d /mnt/pool/full-pool/syncoid ]]") target.succeed("[[ -d /mnt/pool/full-pool/syncoid ]]")
source.systemctl("start --wait syncoid-pool-compat.service")
target.succeed("cat /mnt/pool/compat/test.txt")
assert len(source.succeed("zfs allow pool")) == 0, "Pool shouldn't have delegated permissions set after syncing snapshots" assert len(source.succeed("zfs allow pool")) == 0, "Pool shouldn't have delegated permissions set after syncing snapshots"
assert len(source.succeed("zfs allow pool/sanoid")) == 0, "Sanoid dataset shouldn't have delegated permissions set after syncing snapshots" assert len(source.succeed("zfs allow pool/sanoid")) == 0, "Sanoid dataset shouldn't have delegated permissions set after syncing snapshots"
assert len(source.succeed("zfs allow pool/syncoid")) == 0, "Syncoid dataset shouldn't have delegated permissions set after syncing snapshots" assert len(source.succeed("zfs allow pool/syncoid")) == 0, "Syncoid dataset shouldn't have delegated permissions set after syncing snapshots"