feat(fs): add zfs split store options
This commit is contained in:
parent
714bf122bf
commit
189eabe42c
|
@ -8,8 +8,8 @@ in {
|
||||||
./ext4.nix
|
./ext4.nix
|
||||||
./f2fs.nix
|
./f2fs.nix
|
||||||
./xfs.nix
|
./xfs.nix
|
||||||
./zfs.nix
|
|
||||||
./bcachefs.nix
|
./bcachefs.nix
|
||||||
|
./zfs
|
||||||
];
|
];
|
||||||
|
|
||||||
options.global.fs = {
|
options.global.fs = {
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
, ... }: with lib; let
|
, ... }: with lib; let
|
||||||
cfg = config.global.fs;
|
cfg = config.global.fs;
|
||||||
in {
|
in {
|
||||||
|
imports = [
|
||||||
|
./split.nix
|
||||||
|
];
|
||||||
|
|
||||||
# -o ashift=12
|
# -o ashift=12
|
||||||
# -O encryption=on -O keyformat=passphrase -O keylocation=prompt
|
# -O encryption=on -O keyformat=passphrase -O keylocation=prompt
|
||||||
# -O compression=on -O mountpoint=none -O xattr=sa -O acltype=posixacl
|
# -O compression=on -O mountpoint=none -O xattr=sa -O acltype=posixacl
|
||||||
|
@ -21,6 +25,19 @@ in {
|
||||||
description = "zfs dataset mountpoints";
|
description = "zfs dataset mountpoints";
|
||||||
};
|
};
|
||||||
externalStore = mkEnableOption "external nix store filesystem";
|
externalStore = mkEnableOption "external nix store filesystem";
|
||||||
|
|
||||||
|
split = {
|
||||||
|
enable = mkEnableOption "zfs state with split nix store";
|
||||||
|
mdProg = mkOption {
|
||||||
|
type = with types; str;
|
||||||
|
default = "/usr/bin/true";
|
||||||
|
description = "mdadm PROGRAM config value";
|
||||||
|
};
|
||||||
|
secret = mkOption {
|
||||||
|
type = with types; str;
|
||||||
|
description = "UUID of secret filesystem";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf (cfg.type == "zfs") {
|
config = mkIf (cfg.type == "zfs") {
|
27
global/fs/zfs/split.nix
Normal file
27
global/fs/zfs/split.nix
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{ 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}
|
||||||
|
'';
|
||||||
|
|
||||||
|
# secret filesystem backed by LUKS on swraid
|
||||||
|
fileSystems."/nix/var/secret" =
|
||||||
|
{ device = "/dev/disk/by-uuid/${cfg.secret}";
|
||||||
|
fsType = "ext4";
|
||||||
|
options = [ "noatime" ];
|
||||||
|
neededForBoot = true;
|
||||||
|
depends = [ "/nix/var" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
# import system state pool after encrypted filesystems become available for key loading
|
||||||
|
boot.initrd.systemd.services."zfs-import-${config.global.fs.store}".after = [ "cryptsetup.target" ];
|
||||||
|
}
|
Loading…
Reference in a new issue