nixcfg/modules/nixos/system/zfs/default.nix

48 lines
1,006 B
Nix
Raw Normal View History

2024-01-11 11:26:46 +01:00
{ config, lib, ... }:
let
cfg = config.plusultra.system.zfs;
inherit (lib) mkEnableOption mkIf mkDefault;
inherit (lib.plusultra) mkOpt enabled;
inherit (lib.types) listOf str;
in
{
options.plusultra.system.zfs = {
enable = mkEnableOption "ZFS support";
pools = mkOpt (listOf str) [ "rpool" ] "The ZFS pools to manage.";
auto-snapshot = {
enable = mkEnableOption "ZFS auto snapshotting";
};
};
config = mkIf cfg.enable {
boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
services.zfs = {
autoScrub = {
enable = true;
pools = cfg.pools;
};
autoSnapshot = mkIf cfg.auto-snapshot.enable {
enable = true;
flags = "-k -p --utc";
weekly = mkDefault 3;
daily = mkDefault 3;
hourly = mkDefault 0;
frequent = mkDefault 0;
monthly = mkDefault 2;
};
};
plusultra = {
tools = {
icehouse = enabled;
};
};
};
}