feat(fs): add zfs replication options
This commit is contained in:
parent
f54f445358
commit
3b69ef638d
|
@ -6,6 +6,7 @@
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./split.nix
|
./split.nix
|
||||||
|
./replication.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
# -o ashift=12
|
# -o ashift=12
|
||||||
|
@ -42,6 +43,24 @@ in {
|
||||||
description = "UUID of store filesystem";
|
description = "UUID of store filesystem";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
replication = {
|
||||||
|
enable = mkEnableOption "zfs replication to remote";
|
||||||
|
remote = mkOption {
|
||||||
|
type = with types; str;
|
||||||
|
description = "remote host as replication destination";
|
||||||
|
};
|
||||||
|
datasets = mkOption {
|
||||||
|
type = with types; listOf str;
|
||||||
|
default = [ "persist" "service" "storage" ];
|
||||||
|
description = "list of filesystems to perform replication for";
|
||||||
|
};
|
||||||
|
sendOptions = mkOption {
|
||||||
|
type = with types; str;
|
||||||
|
default = "w";
|
||||||
|
description = "send options for all datasets";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf (cfg.type == "zfs") {
|
config = mkIf (cfg.type == "zfs") {
|
||||||
|
|
29
global/fs/zfs/replication.nix
Normal file
29
global/fs/zfs/replication.nix
Normal 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" ];
|
||||||
|
}
|
Loading…
Reference in a new issue