feat(fs): add zfs split store options
This commit is contained in:
parent
714bf122bf
commit
189eabe42c
3 changed files with 45 additions and 1 deletions
64
global/fs/zfs/default.nix
Normal file
64
global/fs/zfs/default.nix
Normal file
|
@ -0,0 +1,64 @@
|
|||
{ pkgs
|
||||
, lib
|
||||
, config
|
||||
, ... }: with lib; let
|
||||
cfg = config.global.fs;
|
||||
in {
|
||||
imports = [
|
||||
./split.nix
|
||||
];
|
||||
|
||||
# -o ashift=12
|
||||
# -O encryption=on -O keyformat=passphrase -O keylocation=prompt
|
||||
# -O compression=on -O mountpoint=none -O xattr=sa -O acltype=posixacl
|
||||
options.global.fs.zfs = {
|
||||
persist = mkOption {
|
||||
type = with types; str;
|
||||
default = cfg.store;
|
||||
description = ''
|
||||
pool for persist dataset
|
||||
defaults to nix store dataset
|
||||
'';
|
||||
};
|
||||
mountpoints = mkOption {
|
||||
type = with types; attrsOf str;
|
||||
description = "zfs dataset mountpoints";
|
||||
};
|
||||
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") {
|
||||
fileSystems = (mapAttrs (path: dataset: {
|
||||
device = "${cfg.zfs.persist}/${dataset}";
|
||||
fsType = "zfs";
|
||||
# required by impermanence
|
||||
neededForBoot = true;
|
||||
}) cfg.zfs.mountpoints) // {
|
||||
"/nix" = (if !cfg.zfs.externalStore then
|
||||
{ device = "${cfg.store}/nix";
|
||||
fsType = "zfs";
|
||||
} else
|
||||
{ inherit (cfg.external) device fsType options; });
|
||||
};
|
||||
global.fs.zfs.mountpoints."/nix/persist" = "persist";
|
||||
|
||||
services.zfs.trim.enable = true;
|
||||
services.zfs.autoSnapshot.enable = true;
|
||||
services.zfs.autoScrub.enable = true;
|
||||
boot.zfs.devNodes = mkDefault "/dev/disk/by-partuuid";
|
||||
boot.kernelPackages = mkDefault config.boot.zfs.package.latestCompatibleLinuxPackages;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue