1
0
Fork 0

System: cleanup filesystem definition

This commit is contained in:
Aires 2024-10-10 14:30:07 -04:00
parent 1486feaaba
commit 89d3bc02bf

View file

@ -5,6 +5,12 @@ let
# LUKS partition will decrypt to /dev/mapper/nixos-root # LUKS partition will decrypt to /dev/mapper/nixos-root
decryptPart = "nixos-root"; decryptPart = "nixos-root";
decryptPath = "/dev/mapper/${decryptPart}"; decryptPath = "/dev/mapper/${decryptPart}";
# Default mount options for your main partitions
primaryPartOpts = [
"compress=zstd"
(lib.mkIf cfg.discard "discard=async").content
];
in in
{ {
options = { options = {
@ -56,15 +62,11 @@ in
# Enable TPM auto-unlocking if configured # Enable TPM auto-unlocking if configured
crypttabExtraOpts = lib.mkIf config.aux.system.bootloader.tpm2.enable [ "tpm2-device=auto" ]; crypttabExtraOpts = lib.mkIf config.aux.system.bootloader.tpm2.enable [ "tpm2-device=auto" ];
}; };
fileSystems = fileSystems = {
{
"/" = { "/" = {
device = decryptPath; device = decryptPath;
fsType = "btrfs"; fsType = "btrfs";
options = [ options = [ "subvol=@" ] ++ primaryPartOpts;
"subvol=@"
"compress=zstd"
] ++ lib.optionals cfg.discard [ "discard=async" ];
}; };
"/boot" = { "/boot" = {
device = cfg.partitions.boot; device = cfg.partitions.boot;
@ -73,37 +75,29 @@ in
"/home" = { "/home" = {
device = decryptPath; device = decryptPath;
fsType = "btrfs"; fsType = "btrfs";
options = [ options = [ "subvol=@home" ] ++ primaryPartOpts;
"subvol=@home"
"compress=zstd"
] ++ lib.optionals cfg.discard [ "discard=async" ];
}; };
"/var/log" = { "/var/log" = {
device = decryptPath; device = decryptPath;
fsType = "btrfs"; fsType = "btrfs";
options = [ options = [ "subvol=@log" ] ++ primaryPartOpts;
"subvol=@log"
"compress=zstd"
] ++ lib.optionals cfg.discard [ "discard=async" ];
}; };
"/nix" = { "/nix" = {
device = decryptPath; device = decryptPath;
fsType = "btrfs"; fsType = "btrfs";
options = [ options = [
"subvol=@nix" "subvol=@nix"
"compress=zstd"
"noatime" "noatime"
] ++ lib.optionals cfg.discard [ "discard=async" ]; ] ++ primaryPartOpts;
}; };
} "/swap" = lib.mkIf cfg.swapFile.enable {
// lib.optionalAttrs cfg.swapFile.enable {
"/swap" = {
device = decryptPath; device = decryptPath;
fsType = "btrfs"; fsType = "btrfs";
options = [ options = [
"subvol=@swap" "subvol=@swap"
"noatime" "noatime"
] ++ lib.optionals cfg.discard [ "discard=async" ]; (lib.mkIf cfg.discard "discard=async").content
];
}; };
}; };