nixos/zfs-replication: add package option (#368310)

authored by

Gaétan Lepage and committed by
GitHub
74d1d9a8 df1ae7f5

+19 -3
+19 -3
nixos/modules/services/backup/zfs-replication.nix
··· 6 6 }: 7 7 let 8 8 cfg = config.services.zfs.autoReplication; 9 - recursive = lib.optionalString cfg.recursive " --recursive"; 10 - followDelete = lib.optionalString cfg.followDelete " --follow-delete"; 11 9 in 12 10 { 13 11 options = { 14 12 services.zfs.autoReplication = { 15 13 enable = lib.mkEnableOption "ZFS snapshot replication"; 14 + 15 + package = lib.mkPackageOption pkgs "zfs-replicate" { }; 16 16 17 17 followDelete = lib.mkOption { 18 18 description = "Remove remote snapshots that don't have a local correspondent."; ··· 76 76 "https://github.com/alunduil/zfs-replicate" 77 77 ]; 78 78 restartIfChanged = false; 79 - serviceConfig.ExecStart = "${pkgs.zfs-replicate}/bin/zfs-replicate${recursive} -l ${lib.escapeShellArg cfg.username} -i ${lib.escapeShellArg cfg.identityFilePath}${followDelete} ${lib.escapeShellArg cfg.host} ${lib.escapeShellArg cfg.remoteFilesystem} ${lib.escapeShellArg cfg.localFilesystem}"; 79 + serviceConfig.ExecStart = 80 + let 81 + args = lib.map lib.escapeShellArg ( 82 + [ 83 + "-l" 84 + cfg.username 85 + "-i" 86 + cfg.identityFilePath 87 + cfg.host 88 + cfg.remoteFilesystem 89 + cfg.localFilesystem 90 + ] 91 + ++ (lib.optional cfg.recursive "--recursive") 92 + ++ (lib.optional cfg.followDelete "--follow-delete") 93 + ); 94 + in 95 + "${lib.getExe cfg.package} ${lib.concatStringSep " " args}"; 80 96 wantedBy = [ 81 97 "zfs-snapshot-daily.service" 82 98 "zfs-snapshot-frequent.service"