57 lines
1016 B
Nix
57 lines
1016 B
Nix
{
|
|
service_configs,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
zfs-key = "/etc/zfs-key";
|
|
in
|
|
{
|
|
system.activationScripts = {
|
|
"zfs-key".text = ''
|
|
#!/bin/sh
|
|
rm -fr ${zfs-key} || true
|
|
cp ${./secrets/zfs-key} ${zfs-key}
|
|
'';
|
|
};
|
|
|
|
boot.zfs.package = pkgs.zfs_unstable;
|
|
boot.initrd.kernelModules = [ "zfs" ];
|
|
|
|
boot.kernelParams = [
|
|
# 2048MB
|
|
"zfs.zfs_arc_max=2048000000"
|
|
];
|
|
|
|
boot.supportedFilesystems = [ "zfs" ];
|
|
boot.zfs.extraPools = [ service_configs.zpool ];
|
|
|
|
services.sanoid = {
|
|
enable = true;
|
|
datasets."${service_configs.zpool}" = {
|
|
recursive = true;
|
|
autoprune = true;
|
|
autosnap = true;
|
|
hourly = 24;
|
|
daily = 30;
|
|
monthly = 12;
|
|
yearly = 4;
|
|
};
|
|
|
|
datasets."${service_configs.zpool}/services/sql" = {
|
|
recursive = true;
|
|
autoprune = true;
|
|
autosnap = true;
|
|
hourly = 12;
|
|
daily = 2;
|
|
monthly = 0;
|
|
yearly = 0;
|
|
};
|
|
};
|
|
|
|
services.zfs = {
|
|
autoScrub.enable = true;
|
|
trim.enable = true;
|
|
};
|
|
}
|