1
0
Fork 0

Compare commits

..

2 commits

3 changed files with 54 additions and 36 deletions

View file

@ -7,7 +7,8 @@
}:
let
luksUUID = "9fdc521b-a037-4070-af47-f54da03675e4";
luksUUID = "9fdc521b-a037-4070-af47-f54da03675e4"; # The UUID of the locked LUKS partition.
rootUUID = "dfb4fc8f-e82b-43a1-91c1-a77acb6337cb"; # The UUID of the unlocked filesystem partition.
in
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
@ -35,7 +36,7 @@ in
enable = true;
devices = {
boot = "/dev/disk/by-uuid/FC20-D155";
btrfs = "/dev/disk/by-uuid/${luksUUID}";
btrfs = "/dev/disk/by-uuid/${rootUUID}";
};
swapFile = {
enable = true;

View file

@ -6,6 +6,10 @@
modulesPath,
...
}:
let
luksUUID = "bcf67e34-339e-40b9-8ffd-bec8f7f55248"; # The UUID of the locked LUKS partition.
rootUUID = "b801fbea-4cb5-4255-bea9-a2ce77d1a1b7"; # The UUID of the unlocked filesystem partition.
in
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
@ -24,8 +28,8 @@
"sd_mod"
"rtsx_pci_sdmmc"
];
luks.devices."luks-bcf67e34-339e-40b9-8ffd-bec8f7f55248" = {
device = "/dev/disk/by-uuid/bcf67e34-339e-40b9-8ffd-bec8f7f55248";
luks.devices."luks-${luksUUID}" = {
device = "/dev/disk/by-uuid/${luksUUID}";
crypttabExtraOpts = [ "tpm2-device=auto" ]; # Enable TPM auto-unlocking
};
};
@ -33,25 +37,16 @@
kernelModules = [ "kvm-amd" ];
};
fileSystems = {
"/" = {
device = "/dev/disk/by-uuid/b801fbea-4cb5-4255-bea9-a2ce77d1a1b7";
fsType = "btrfs";
options = [ "subvol=@,compress=zstd,discard" ];
# Configure the main filesystem.
aux.system.filesystem.btrfs = {
enable = true;
devices = {
boot = "/dev/disk/by-uuid/FC20-D155";
btrfs = "/dev/disk/by-uuid/${rootUUID}";
};
"/home" = {
device = "/dev/disk/by-uuid/b801fbea-4cb5-4255-bea9-a2ce77d1a1b7";
fsType = "btrfs";
options = [ "subvol=@home,compress=zstd,discard" ];
};
"/swap" = {
device = "/dev/disk/by-uuid/b801fbea-4cb5-4255-bea9-a2ce77d1a1b7";
fsType = "btrfs";
options = [ "subvol=@swap" ];
};
"/boot" = {
device = "/dev/disk/by-uuid/AFCB-D880";
fsType = "vfat";
swapFile = {
enable = true;
size = 16384;
};
};

View file

@ -2,11 +2,7 @@
let
cfg = config.aux.system.filesystem.btrfs;
standardMountOpts = [
"compress=zstd"
"discard=async"
"noatime"
];
standardMountOpts = [ "compress=zstd" ];
in
{
options = {
@ -24,6 +20,16 @@ in
default = "";
};
};
subvolumes = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = "Which subvolumes to mount. Leave as the default to create all standard subvolumes.";
default = [
"/"
"/home"
"/nix"
"/var/log"
];
};
swapFile = {
enable = lib.mkEnableOption (lib.mdDoc "Enables the creation of a swap file.");
size = lib.mkOption {
@ -50,36 +56,52 @@ in
];
fileSystems =
{
"/" = {
"/" = lib.mkIf (builtins.elem "/" cfg.subvolumes) {
device = cfg.devices.btrfs;
fsType = "btrfs";
options = [ "subvol=@" ] ++ standardMountOpts;
options = [
"subvol=@"
"compress=zstd"
];
};
"/boot" = {
device = cfg.devices.boot;
fsType = "vfat";
};
"/home" = {
"/home" = lib.mkIf (builtins.elem "/home" cfg.subvolumes) {
device = cfg.devices.btrfs;
fsType = "btrfs";
options = [ "subvol=@home" ] ++ standardMountOpts;
options = [
"subvol=@home"
"compress=zstd"
];
};
"/var/log" = {
"/var/log" = lib.mkIf (builtins.elem "/var/log" cfg.subvolumes) {
device = cfg.devices.btrfs;
fsType = "btrfs";
options = [ "subvol=@log" ] ++ standardMountOpts;
options = [
"subvol=@log"
"compress=zstd"
];
};
"/nix" = {
"/nix" = lib.mkIf (builtins.elem "/nix" cfg.subvolumes) {
device = cfg.devices.btrfs;
fsType = "btrfs";
options = [ "subvol=@nix" ] ++ standardMountOpts;
options = [
"subvol=@nix"
"compress=zstd"
"noatime"
];
};
}
// lib.optionalAttrs cfg.swapFile.enable {
"/swap" = {
device = cfg.devices.btrfs;
fsType = "btrfs";
options = [ "subvol=@swap" ];
options = [
"subvol=@swap"
"noatime"
];
};
};