feat(fs): add zfs replication options

This commit is contained in:
514fpv 2024-02-10 00:57:35 +08:00
parent f54f445358
commit 3b69ef638d
Signed by: koishi
SSH key fingerprint: SHA256:axz0uIzzY+5W19i7QOUuiw5LSqhKfCBKPf3L4xFRxLw
2 changed files with 48 additions and 0 deletions

View file

@ -0,0 +1,29 @@
{ pkgs
, lib
, config
, ... }: with lib; let
cfg = config.global.fs.zfs.replication;
in mkIf cfg.enable {
services.syncoid = {
enable = mkDefault true;
interval = mkDefault "daily";
sshKey = mkDefault "/var/lib/syncoid/.ssh/id_ed25519";
commonArgs = [
"--recursive"
"--compress=lz4"
"--mbuffer-size=128M"
];
localSourceAllow = options.services.syncoid.localSourceAllow.default ++ [ "mount" ];
commands = (lists.foldr (name: commands: commands // {
"${config.global.fs.store}/${name}" = {
inherit (cfg) sendOptions;
target = "${cfg.remote}/${name}";
};
}) { }) cfg.datasets;
};
users.users.syncoid.uid = 82;
users.groups.syncoid.gid = 82;
environment.persistence."/nix/persist/fhs".directories = [ "/var/lib/syncoid" ];
}