summary refs log tree commit diff
diff options
context:
space:
mode:
authorJulien Moutinho <julm+nixpkgs@sourcephile.fr>2022-08-22 18:53:35 +0200
committerJulien Moutinho <julm+nixpkgs@sourcephile.fr>2022-08-22 18:56:47 +0200
commit9a945090891fd44047c6ce35f62b7ededddabbb4 (patch)
treee54746d65eacf05499b7930e1c5c43019c739b22
parent5c91de512dac418bb3a13d76b160af060cef3aaf (diff)
downloadnixpkgs-9a945090891fd44047c6ce35f62b7ededddabbb4.tar
nixpkgs-9a945090891fd44047c6ce35f62b7ededddabbb4.tar.gz
nixpkgs-9a945090891fd44047c6ce35f62b7ededddabbb4.tar.bz2
nixpkgs-9a945090891fd44047c6ce35f62b7ededddabbb4.tar.lz
nixpkgs-9a945090891fd44047c6ce35f62b7ededddabbb4.tar.xz
nixpkgs-9a945090891fd44047c6ce35f62b7ededddabbb4.tar.zst
nixpkgs-9a945090891fd44047c6ce35f62b7ededddabbb4.zip
nixos/sanoid: fix aliased options
Fixes https://github.com/NixOS/nixpkgs/issues/181561
-rw-r--r--nixos/modules/services/backup/sanoid.nix4
-rw-r--r--nixos/tests/sanoid.nix12
2 files changed, 14 insertions, 2 deletions
diff --git a/nixos/modules/services/backup/sanoid.nix b/nixos/modules/services/backup/sanoid.nix
index 0c01aa57f7e..40a2c9aae81 100644
--- a/nixos/modules/services/backup/sanoid.nix
+++ b/nixos/modules/services/backup/sanoid.nix
@@ -130,8 +130,8 @@ in
       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.";
diff --git a/nixos/tests/sanoid.nix b/nixos/tests/sanoid.nix
index 97833c37e6e..411ebcead9f 100644
--- a/nixos/tests/sanoid.nix
+++ b/nixos/tests/sanoid.nix
@@ -34,6 +34,7 @@ in {
           autosnap = true;
         };
         datasets."pool/sanoid".use_template = [ "test" ];
+        datasets."pool/compat".useTemplate = [ "test" ];
         extraArgs = [ "--verbose" ];
       };
 
@@ -51,6 +52,12 @@ in {
 
           # 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" ];
+          };
         };
       };
     };
@@ -70,6 +77,7 @@ in {
         "udevadm settle",
         "zpool create pool -R /mnt /dev/vdb1",
         "zfs create pool/sanoid",
+        "zfs create pool/compat",
         "zfs create pool/syncoid",
         "udevadm settle",
     )
@@ -94,6 +102,7 @@ in {
 
     # 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"
@@ -111,6 +120,9 @@ in {
     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"
     assert len(source.succeed("zfs allow pool/syncoid")) == 0, "Syncoid dataset shouldn't have delegated permissions set after syncing snapshots"