nix: add sanoid module + enable on loki,t14

This commit is contained in:
surtur 2023-12-12 20:25:35 +01:00
parent bac5f3e9e7
commit fdb22c1152
Signed by: wanderer
SSH Key Fingerprint: SHA256:MdCZyJ2sHLltrLBp0xQO0O1qTW9BT/xl5nXkDvhlMCI
3 changed files with 101 additions and 0 deletions

@ -21,6 +21,7 @@
../../modules/base.nix ../../modules/base.nix
../../modules/dnscrypt.nix ../../modules/dnscrypt.nix
../../modules/sanoid.nix
../../modules/uptime-kuma.nix ../../modules/uptime-kuma.nix
../../modules/zram.nix ../../modules/zram.nix
]; ];
@ -195,6 +196,39 @@
]; ];
}; };
sanoid = {
enable = true;
interval = "*:0/5";
datasets = {
"zroot/DATA/services/nextcloud" = {
useTemplate = ["frequent"];
recursive = "zfs";
};
"zroot/DATA/services/gonic" = {
useTemplate = ["production"];
recursive = "zfs";
};
"zroot/DATA/services/attic" = {
useTemplate = ["production"];
recursive = "zfs";
};
"zroot/DATA/services/uptime-kuma" = {
useTemplate = ["production"];
recursive = "zfs";
};
# rootfs.
"zroot/ROOT/nixos" = {
useTemplate = ["production"];
recursive = "zfs";
};
# nix stuff, just to make sure.
"zroot/nix" = {
useTemplate = ["production"];
recursive = "zfs";
};
};
};
# TS is enabled in the imported module, this is additional config. # TS is enabled in the imported module, this is additional config.
tailscale = { tailscale = {
useRoutingFeatures = "both"; useRoutingFeatures = "both";

@ -14,6 +14,7 @@
../../modules/base.nix ../../modules/base.nix
../../modules/dnscrypt.nix ../../modules/dnscrypt.nix
../../modules/firejail.nix ../../modules/firejail.nix
../../modules/sanoid.nix
../../modules/zram.nix ../../modules/zram.nix
]; ];
@ -333,6 +334,27 @@
]; ];
}; };
sanoid = {
enable = true;
interval = "*:0/5";
datasets = {
"zroot/userdata" = {
useTemplate = ["frequent"];
recursive = "zfs";
};
"zroot/system/nixos" = {
useTemplate = ["production"];
recursive = "zfs";
};
"zroot/local/nix" = {
useTemplate = ["production"];
};
"zroot/local/xper" = {
useTemplate = ["production"];
};
};
};
syncthing = { syncthing = {
enable = true; enable = true;
openDefaultPorts = true; openDefaultPorts = true;

45
nix/modules/sanoid.nix Normal file

@ -0,0 +1,45 @@
{
config,
lib,
pkgs,
...
}: {
services.sanoid = {
templates = {
production = {
frequently = 5;
hourly = 96;
daily = 30;
monthly = 3;
yearly = 0;
autosnap = true;
autoprune = true;
};
frequent = {
frequently = 90;
frequent_period = 5;
hourly = 96;
daily = 30;
monthly = 3;
yearly = 0;
autosnap = true;
autoprune = true;
};
};
};
systemd.timers.sanoid.timerConfig = {
Persistent = true;
# WantedBy =["timers.target"];
};
environment.systemPackages = with pkgs; [
mbuffer
zstd
];
users.users.root.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOrlXIj3oWbWrFUZnhccd/uqM2D/yRiKOEwfD6xbngJ7 syncoid pull backups"
];
}