nixos/sanoid: fix aliased options

Fixes https://github.com/NixOS/nixpkgs/issues/181561

Changed files
+14 -2
nixos
modules
services
backup
tests
+2 -2
nixos/modules/services/backup/sanoid.nix
···
type = types.attrsOf (types.submodule ({ config, options, ... }: {
freeformType = datasetSettingsType;
options = commonOptions // datasetOptions;
-
config.use_template = mkAliasDefinitions (mkDefault options.useTemplate or { });
-
config.process_children_only = mkAliasDefinitions (mkDefault options.processChildrenOnly or { });
+
config.use_template = modules.mkAliasAndWrapDefsWithPriority id (options.useTemplate or { });
+
config.process_children_only = modules.mkAliasAndWrapDefsWithPriority id (options.processChildrenOnly or { });
}));
default = { };
description = lib.mdDoc "Datasets to snapshot.";
+12
nixos/tests/sanoid.nix
···
autosnap = true;
};
datasets."pool/sanoid".use_template = [ "test" ];
+
datasets."pool/compat".useTemplate = [ "test" ];
extraArgs = [ "--verbose" ];
};
···
# Test pool without parent (regression test for https://github.com/NixOS/nixpkgs/pull/180111)
"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" ];
+
};
};
};
};
···
"udevadm settle",
"zpool create pool -R /mnt /dev/vdb1",
"zfs create pool/sanoid",
+
"zfs create pool/compat",
"zfs create pool/syncoid",
"udevadm settle",
)
···
# Take snapshot with sanoid
source.succeed("touch /mnt/pool/sanoid/test.txt")
+
source.succeed("touch /mnt/pool/compat/test.txt")
source.systemctl("start --wait sanoid.service")
assert len(source.succeed("zfs allow pool")) == 0, "Pool shouldn't have delegated permissions set after snapshotting"
···
source.systemctl("start --wait syncoid-pool.service")
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/sanoid")) == 0, "Sanoid dataset shouldn't have delegated permissions set after syncing snapshots"