88 lines
1.7 KiB
Nix
88 lines
1.7 KiB
Nix
{
|
|
service_configs,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
# DO NOT CHANGE
|
|
# path is set via a zfs property
|
|
zfs-key = "/etc/zfs-key";
|
|
in
|
|
{
|
|
system.activationScripts = {
|
|
# TODO! replace with proper secrets management
|
|
"zfs-key".text = ''
|
|
#!/bin/sh
|
|
rm -fr ${zfs-key} || true
|
|
cp ${./secrets/zfs-key} ${zfs-key}
|
|
chmod 0500 ${zfs-key}
|
|
chown root:wheel ${zfs-key}
|
|
'';
|
|
};
|
|
|
|
boot.zfs.package = pkgs.zfs;
|
|
boot.initrd.kernelModules = [ "zfs" ];
|
|
|
|
boot.kernelParams =
|
|
let
|
|
mb = 20000;
|
|
in
|
|
[
|
|
"zfs.zfs_arc_max=${builtins.toString (mb * 1000000)}"
|
|
];
|
|
|
|
boot.supportedFilesystems = [ "zfs" ];
|
|
boot.zfs.extraPools = [
|
|
service_configs.zpool_ssds
|
|
service_configs.zpool_hdds
|
|
];
|
|
|
|
services.sanoid = {
|
|
enable = true;
|
|
datasets."${service_configs.zpool_ssds}" = {
|
|
recursive = true;
|
|
autoprune = true;
|
|
autosnap = true;
|
|
hourly = 5;
|
|
daily = 7;
|
|
monthly = 3;
|
|
yearly = 0;
|
|
};
|
|
|
|
datasets."${service_configs.zpool_ssds}/services/sql" = {
|
|
recursive = true;
|
|
autoprune = true;
|
|
autosnap = true;
|
|
hourly = 12;
|
|
daily = 2;
|
|
monthly = 0;
|
|
yearly = 0;
|
|
};
|
|
|
|
datasets."${service_configs.zpool_ssds}/services/jellyfin_cache" = {
|
|
recursive = true;
|
|
autoprune = true;
|
|
autosnap = true;
|
|
hourly = 0;
|
|
daily = 0;
|
|
monthly = 0;
|
|
yearly = 0;
|
|
};
|
|
|
|
datasets."${service_configs.zpool_hdds}" = {
|
|
recursive = true;
|
|
autoprune = true;
|
|
autosnap = true;
|
|
hourly = 0;
|
|
daily = 0;
|
|
monthly = 0;
|
|
yearly = 0;
|
|
};
|
|
};
|
|
|
|
services.zfs = {
|
|
autoScrub.enable = true;
|
|
trim.enable = true;
|
|
};
|
|
}
|