nixos/zfs-replication: add package option
This commit is contained in:
@@ -6,14 +6,14 @@
|
|||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.services.zfs.autoReplication;
|
cfg = config.services.zfs.autoReplication;
|
||||||
recursive = lib.optionalString cfg.recursive " --recursive";
|
|
||||||
followDelete = lib.optionalString cfg.followDelete " --follow-delete";
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
services.zfs.autoReplication = {
|
services.zfs.autoReplication = {
|
||||||
enable = lib.mkEnableOption "ZFS snapshot replication";
|
enable = lib.mkEnableOption "ZFS snapshot replication";
|
||||||
|
|
||||||
|
package = lib.mkPackageOption pkgs "zfs-replicate" { };
|
||||||
|
|
||||||
followDelete = lib.mkOption {
|
followDelete = lib.mkOption {
|
||||||
description = "Remove remote snapshots that don't have a local correspondent.";
|
description = "Remove remote snapshots that don't have a local correspondent.";
|
||||||
default = true;
|
default = true;
|
||||||
@@ -76,7 +76,23 @@ in
|
|||||||
"https://github.com/alunduil/zfs-replicate"
|
"https://github.com/alunduil/zfs-replicate"
|
||||||
];
|
];
|
||||||
restartIfChanged = false;
|
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 = [
|
wantedBy = [
|
||||||
"zfs-snapshot-daily.service"
|
"zfs-snapshot-daily.service"
|
||||||
"zfs-snapshot-frequent.service"
|
"zfs-snapshot-frequent.service"
|
||||||
|
|||||||
Reference in New Issue
Block a user