1
0
Fork 0

Modules: add optional subvolumes parameter to filesystems

This commit is contained in:
Aires 2024-07-03 11:33:28 -04:00
parent 73c9338b88
commit 3a1bc51b68

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"
];
};
};