This commit is contained in:
mjallen18
2025-09-06 10:28:07 -05:00
parent 6b44792e06
commit 30fb21e062
5 changed files with 107 additions and 4 deletions

View File

@@ -17,6 +17,8 @@ in
enableSwap = mkBoolOpt false "Enable swap";
enableLuks = mkBoolOpt false "Enable Luks";
swapSize = mkOpt types.str "16G" "size of swap part";
};
}

View File

@@ -56,6 +56,62 @@ let
};
};
# BTRFS root partition configuration
encBtrfsRoot = {
name = "cryptroot";
size = "100%";
content = {
type = "luks";
name = "cryptroot";
extraOpenArgs = [
"--allow-discards"
"--perf-no_read_workqueue"
"--perf-no_write_workqueue"
];
settings = {crypttabExtraOpts = ["fido2-device=auto" "token-timeout=10"];};
content = {
type = "btrfs";
extraArgs = [ "-f" ]; # Override existing partition
# Subvolumes must set a mountpoint in order to be mounted,
# unless their parent is mounted
subvolumes = {
"home" = {
mountOptions = [ "compress=zstd" ];
mountpoint = "/home";
};
"root" = {
mountOptions = [
"compress=zstd"
"noatime"
];
mountpoint = "/root";
};
"nix" = {
mountOptions = [
"compress=zstd"
"noatime"
];
mountpoint = "/nix";
};
"etc" = {
mountOptions = [
"compress=zstd"
"noatime"
];
mountpoint = "/etc";
};
"log" = {
mountOptions = [
"compress=zstd"
"noatime"
];
mountpoint = "/var/log";
};
};
};
};
};
# BCacheFS root partition configuration
bcachefsRoot = {
name = "bcachefs-root";
@@ -108,7 +164,7 @@ in
size = cfg.swapSize;
};
root = if cfg.filesystem == "btrfs" then btrfsRoot else bcachefsRoot;
root = if cfg.filesystem == "btrfs" then ( if cfg.enableLuks then encBtrfsRoot else btrfsRoot) else bcachefsRoot;
};
};
};