2024-02-10 00:16:09 +08:00
|
|
|
{ pkgs
|
|
|
|
, lib
|
|
|
|
, config
|
|
|
|
, ... }: with lib; let
|
|
|
|
cfg = config.global.fs.zfs.split;
|
|
|
|
in mkIf cfg.enable {
|
|
|
|
# unconditionally enable fstrim for xfs and ext4
|
|
|
|
services.fstrim.enable = mkDefault true;
|
|
|
|
|
|
|
|
# enable swraid for split raid1 system array
|
|
|
|
boot.swraid.enable = mkDefault true;
|
|
|
|
boot.swraid.mdadmConf = mkDefault ''
|
|
|
|
PROGRAM ${cfg.mdProg}
|
|
|
|
'';
|
|
|
|
|
2024-02-10 00:20:43 +08:00
|
|
|
# secret filesystem backed by swraid
|
2024-02-10 00:16:09 +08:00
|
|
|
fileSystems."/nix/var/secret" =
|
|
|
|
{ device = "/dev/disk/by-uuid/${cfg.secret}";
|
|
|
|
fsType = "ext4";
|
|
|
|
options = [ "noatime" ];
|
|
|
|
neededForBoot = true;
|
|
|
|
depends = [ "/nix/var" ];
|
|
|
|
};
|
|
|
|
|
2024-02-10 00:20:43 +08:00
|
|
|
# external store backed by swraid
|
|
|
|
global.fs = {
|
|
|
|
zfs.externalStore = mkDefault true;
|
|
|
|
external.device = "/dev/disk/by-uuid/${cfg.store}";
|
|
|
|
external.fsType = "xfs";
|
|
|
|
external.options = [ "noatime" ];
|
|
|
|
};
|
|
|
|
|
2024-02-10 00:16:09 +08:00
|
|
|
# import system state pool after encrypted filesystems become available for key loading
|
2024-10-26 01:02:09 +08:00
|
|
|
boot.initrd.systemd.services."zfs-import-${config.global.fs.store}".after = [ "sysroot-nix-var-secret.mount" "cryptsetup.target" ];
|
2024-02-10 00:16:09 +08:00
|
|
|
}
|