2020-10-01 15:46:04 -07:00
|
|
|
{ config, options, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
with lib.my;
|
|
|
|
let cfg = config.modules.hardware.fs;
|
|
|
|
in {
|
|
|
|
options.modules.hardware.fs = {
|
|
|
|
enable = mkBoolOpt false;
|
|
|
|
zfs.enable = mkBoolOpt false;
|
|
|
|
ssd.enable = mkBoolOpt false;
|
|
|
|
# TODO automount.enable = mkBoolOpt false;
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
|
|
{
|
|
|
|
programs.udevil.enable = true;
|
|
|
|
|
|
|
|
# Support for more filesystems, mostly to support external drives
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
sshfs
|
2020-12-21 19:36:14 -08:00
|
|
|
exfat # Windows drives
|
|
|
|
ntfs3g # Windows drives
|
|
|
|
hfsprogs # MacOS drives
|
2020-10-01 15:46:04 -07:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
(mkIf (!cfg.zfs.enable && cfg.ssd.enable) {
|
|
|
|
services.fstrim.enable = true;
|
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf cfg.zfs.enable (mkMerge [
|
|
|
|
{
|
|
|
|
boot.loader.grub.copyKernels = true;
|
|
|
|
boot.supportedFilesystems = [ "zfs" ];
|
|
|
|
boot.zfs.devNodes = "/dev/disk/by-partuuid";
|
|
|
|
services.zfs.autoScrub.enable = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
(mkIf cfg.ssd.enable {
|
|
|
|
# Will only TRIM SSDs; skips over HDDs
|
|
|
|
services.fstrim.enable = false;
|
|
|
|
services.zfs.trim.enable = true;
|
|
|
|
})
|
|
|
|
]))
|
|
|
|
]);
|
|
|
|
}
|