feat(fs): add f2fs and zfs
This commit is contained in:
parent
da90dbc46e
commit
4d31fbbe2a
|
@ -6,19 +6,22 @@
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./ext4.nix
|
./ext4.nix
|
||||||
|
./f2fs.nix
|
||||||
./xfs.nix
|
./xfs.nix
|
||||||
|
./zfs.nix
|
||||||
#./bcachefs.nix
|
#./bcachefs.nix
|
||||||
./btrfs.nix
|
./btrfs.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
options.global.fs = {
|
options.global.fs = {
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = with types; enum [ "ext4" "xfs" "bcachefs" "btrfs" ];
|
type = with types; enum [ "ext4" "f2fs" "xfs" "zfs" "bcachefs" "btrfs" ];
|
||||||
default = "bcachefs";
|
default = "bcachefs";
|
||||||
description = "filesystem type to use for persistent state storage";
|
description = "filesystem type to use for persistent state storage";
|
||||||
};
|
};
|
||||||
store = mkOption {
|
store = mkOption {
|
||||||
type = with types; str;
|
type = with types; str;
|
||||||
|
default = config.networking.hostName;
|
||||||
description = "UUID/dataset of nix store backing device";
|
description = "UUID/dataset of nix store backing device";
|
||||||
};
|
};
|
||||||
esp = {
|
esp = {
|
||||||
|
|
10
global/fs/f2fs.nix
Normal file
10
global/fs/f2fs.nix
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{ lib
|
||||||
|
, config
|
||||||
|
, ... }: with lib; let
|
||||||
|
cfg = config.global.fs;
|
||||||
|
in mkIf (cfg.type == "f2fs") {
|
||||||
|
fileSystems."/nix" =
|
||||||
|
{ device = "/dev/disk/by-uuid/${cfg.store}";
|
||||||
|
fsType = "f2fs";
|
||||||
|
};
|
||||||
|
}
|
41
global/fs/zfs.nix
Normal file
41
global/fs/zfs.nix
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{ pkgs
|
||||||
|
, lib
|
||||||
|
, config
|
||||||
|
, ... }: with lib; let
|
||||||
|
cfg = config.global.fs;
|
||||||
|
in {
|
||||||
|
options.global.fs.zfs = {
|
||||||
|
persist = mkOption {
|
||||||
|
type = with types; str;
|
||||||
|
default = cfg.store;
|
||||||
|
description = ''
|
||||||
|
pool for persist dataset
|
||||||
|
defaults to nix store dataset
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf (cfg.type == "zfs") {
|
||||||
|
fileSystems = {
|
||||||
|
"/nix" =
|
||||||
|
{ device = "${cfg.store}/nix";
|
||||||
|
fsType = "zfs";
|
||||||
|
};
|
||||||
|
"/nix/persist" =
|
||||||
|
{ device = "${cfg.zfs.persist}/persist";
|
||||||
|
fsType = "zfs";
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
} // (mapAttrs' (name: opts: nameValuePair
|
||||||
|
"/nix/persist/home/${name}" {
|
||||||
|
device = "${cfg.zfs.persist}/home/${name}";
|
||||||
|
fsType = "zfs";
|
||||||
|
neededForBoot = true;
|
||||||
|
}) (filterAttrs (n: _: n != "root") config.users.profiles));
|
||||||
|
|
||||||
|
services.zfs.trim.enable = true;
|
||||||
|
services.zfs.autoSnapshot.enable = true;
|
||||||
|
services.zfs.autoScrub.enable = true;
|
||||||
|
boot.zfs.devNodes = mkDefault "/dev/disk/by-partuuid";
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue