nixos/syncoid: fix permissions without --no-sync-snap

After 733acfa140d5b73bc69c53c4ebd90ccc5f281f0e, syncoid would fail to
run if commonArgs did not include [ "--no-sync-snap" ], since it would
not have permissions to create or destroy snapshots.

Changed files
+8 -9
nixos
modules
services
backup
tests
+8 -8
nixos/modules/services/backup/syncoid.nix
···
])) (attrValues cfg.commands);
after = [ "zfs.target" ];
serviceConfig = {
-
ExecStartPre = (map (pool: lib.escapeShellArgs [
-
"+/run/booted-system/sw/bin/zfs" "allow"
-
cfg.user "hold,send" pool
-
]) (getPools "source")) ++
-
(map (pool: lib.escapeShellArgs [
-
"+/run/booted-system/sw/bin/zfs" "allow"
-
cfg.user "create,mount,receive,rollback" pool
-
]) (getPools "target"));
+
ExecStartPre = let
+
allowCmd = permissions: pool: lib.escapeShellArgs [
+
"+/run/booted-system/sw/bin/zfs" "allow"
+
cfg.user (concatStringsSep "," permissions) pool
+
];
+
in
+
(map (allowCmd [ "hold" "send" "snapshot" "destroy" ]) (getPools "source")) ++
+
(map (allowCmd [ "create" "mount" "receive" "rollback" ]) (getPools "target"));
User = cfg.user;
Group = cfg.group;
};
-1
nixos/tests/sanoid.nix
···
services.syncoid = {
enable = true;
sshKey = "/var/lib/syncoid/id_ecdsa";
-
commonArgs = [ "--no-sync-snap" ];
commands."pool/test".target = "root@target:pool/test";
};
};