51 lines
1.2 KiB
Nix
Raw Normal View History

{
config,
pkgs,
lib,
...
}:
2025-01-20 22:35:40 -05:00
let
2025-02-14 15:36:54 -05:00
cfg = config.nmasur.presets.zfs;
2025-01-20 22:35:40 -05:00
in
2024-04-20 09:42:06 -04:00
{
2023-02-25 11:22:31 -05:00
2025-02-14 15:36:54 -05:00
options.nmasur.presets.zfs.enable = lib.mkEnableOption "ZFS file system";
2023-02-25 11:22:31 -05:00
2025-01-20 22:35:40 -05:00
config = lib.mkIf cfg.enable {
2023-02-25 11:22:31 -05:00
# Only use compatible Linux kernel, since ZFS can be behind
boot.kernelPackages = pkgs.linuxPackages; # Defaults to latest LTS
2025-01-20 22:35:40 -05:00
boot.kernelParams = [ "nohibernate" ]; # ZFS does not work with hibernation
boot.supportedFilesystems = [ "zfs" ];
2024-04-20 09:42:06 -04:00
services.prometheus.exporters.zfs.enable = config.prometheus.exporters.enable;
prometheus.scrapeTargets = [
2024-04-20 09:42:06 -04:00
"127.0.0.1:${builtins.toString config.services.prometheus.exporters.zfs.port}"
];
2025-02-16 15:40:15 -05:00
zramSwap.enable = true;
swapDevices = [
{
device = "/swapfile";
size = 4 * 1024; # 4 GB
}
];
boot.zfs = {
# Automatically load the ZFS pool on boot
extraPools = [ "tank" ];
# Only try to decrypt datasets with keyfiles
requestEncryptionCredentials = [
"tank/archive"
"tank/generic"
"tank/nextcloud"
"tank/generic/git"
];
# If password is requested and fails, continue to boot eventually
passwordTimeout = 300;
};
};
2023-02-25 11:22:31 -05:00
}