Skip to content

Commit

Permalink
nixos/zfs-replication: add package option
Browse files Browse the repository at this point in the history
(cherry picked from commit e5f2ebf)
  • Loading branch information
GaetanLepage authored and github-actions[bot] committed Dec 26, 2024
1 parent f941719 commit c4b251f
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions nixos/modules/services/backup/zfs-replication.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
}:
let
cfg = config.services.zfs.autoReplication;
recursive = lib.optionalString cfg.recursive " --recursive";
followDelete = lib.optionalString cfg.followDelete " --follow-delete";
in
{
options = {
services.zfs.autoReplication = {
enable = lib.mkEnableOption "ZFS snapshot replication";

package = lib.mkPackageOption pkgs "zfs-replicate" { };

followDelete = lib.mkOption {
description = "Remove remote snapshots that don't have a local correspondent.";
default = true;
Expand Down Expand Up @@ -76,7 +76,23 @@ in
"https://github.com/alunduil/zfs-replicate"
];
restartIfChanged = false;
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}";
serviceConfig.ExecStart =
let
args = lib.map lib.escapeShellArg (
[
"-l"
cfg.username
"-i"
cfg.identityFilePath
cfg.host
cfg.remoteFilesystem
cfg.localFilesystem
]
++ (lib.optional cfg.recursive "--recursive")
++ (lib.optional cfg.followDelete "--follow-delete")
);
in
"${lib.getExe cfg.package} ${lib.concatStringSep " " args}";
wantedBy = [
"zfs-snapshot-daily.service"
"zfs-snapshot-frequent.service"
Expand Down

0 comments on commit c4b251f

Please sign in to comment.