aboutsummaryrefslogtreecommitdiffstats
path: root/modules/by-name/di/disks
diff options
context:
space:
mode:
Diffstat (limited to 'modules/by-name/di/disks')
-rw-r--r--modules/by-name/di/disks/hibernate.nix7
-rw-r--r--modules/by-name/di/disks/module.nix106
2 files changed, 72 insertions, 41 deletions
diff --git a/modules/by-name/di/disks/hibernate.nix b/modules/by-name/di/disks/hibernate.nix
index e983f9c7..d3f8fe8b 100644
--- a/modules/by-name/di/disks/hibernate.nix
+++ b/modules/by-name/di/disks/hibernate.nix
@@ -48,7 +48,8 @@
systemd-hibernate.serviceConfig.Environment = "SYSTEMD_BYPASS_HIBERNATION_MEMORY_CHECK=1";
systemd-logind.serviceConfig.Environment = "SYSTEMD_BYPASS_HIBERNATION_MEMORY_CHECK=1";
};
- sleep.extraConfig = ''
- HibernateDelaySec=5m
- '';
+
+ sleep.settings.Sleep = {
+ HibernateDelaySec = "10m";
+ };
}
diff --git a/modules/by-name/di/disks/module.nix b/modules/by-name/di/disks/module.nix
index 7d5cb9bf..ed5c939a 100644
--- a/modules/by-name/di/disks/module.nix
+++ b/modules/by-name/di/disks/module.nix
@@ -11,9 +11,9 @@
config,
lib,
pkgs,
+ modules,
...
}: let
- # FIXME: The iso redeploy requires a bigger efi partition <2024-05-12>
cfg = config.soispha.disks;
defaultMountOptions = [
"compress-force=zstd:15" # This saves disk space, at a performance cost
@@ -33,22 +33,27 @@ in {
ssd = lib.mkEnableOption "ssd specific improvements, like trim";
swap = {
- uuid = lib.mkOption {
+ ram_size = lib.mkOption {
type = lib.types.str;
- example = lib.literalExpression "d1d20ae7-3d8a-44da-86da-677dbbb10c89";
- description = "The uuid of the swapfile";
- };
- resumeOffset = lib.mkOption {
- type = lib.types.str;
- example = lib.literalExpression "134324224";
- description = "The resume offset of the swapfile";
+ example = lib.literalExpression "16G";
+ description = "The size of the ram (translates to the swapfile size)";
};
};
};
+ imports = [
+ modules.disko.nixosModules.default
+ ];
+
config = lib.mkIf cfg.enable {
systemd = lib.recursiveUpdate (import ./hibernate.nix {inherit pkgs;}) (import ./fstrim.nix {inherit pkgs lib cfg;});
+ services.btrfs.autoScrub = {
+ enable = true;
+ fileSystems = ["/srv" "/nix"];
+ interval = "monthly";
+ };
+
disko.devices = {
disk = {
main = {
@@ -56,21 +61,44 @@ in {
content = {
type = "gpt";
partitions = {
+ ESP = {
+ # 2GiB plus 512MiB for tails ISO and normal boot stuff
+ size = "2600M";
+
+ type = "EF00";
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ mountOptions = ["umask=0077"];
+ };
+ };
+
+ nix = {
+ size = "30G";
+ content = {
+ type = "luks";
+ name = "nixos-store";
+ extraOpenArgs = ["--allow-discards"];
+ content = {
+ type = "btrfs";
+ extraArgs = ["-f" "--label nixos-store"]; # Override existing partitions
+ mountpoint = "/nix";
+ mountOptions = defaultMountOptions;
+ };
+ };
+ };
+
root = {
size = "100%";
- name = "root";
content = {
type = "luks";
- name = "nixos";
+ name = "nixos-root";
extraOpenArgs = ["--allow-discards"];
content = {
type = "btrfs";
- extraArgs = ["-f" "--label nixos"]; # Override existing partitions
+ extraArgs = ["-f" "--label nixos-root"]; # Override existing partitions
subvolumes = {
- "nix" = {
- mountpoint = "/nix";
- mountOptions = defaultMountOptions;
- };
"persistent-storage" = {
mountpoint = "/srv";
mountOptions = defaultMountOptions;
@@ -81,22 +109,21 @@ in {
};
"swap" = {
mountpoint = "/swap";
- mountOptions = defaultMountOptions;
+ mountOptions = [
+ "noatime" # should have some performance upsides, and I don't use it anyways
+ "lazytime" # make time changes in memory
+ ];
+ swap = {
+ swapfile = {
+ priority = -1; # lower than zramSwap, just in case
+ size = cfg.swap.ram_size;
+ };
+ };
};
};
};
};
};
- boot = {
- type = "EF00";
- size = "512M";
- name = "boot";
- content = {
- type = "filesystem";
- format = "vfat";
- mountpoint = "/boot";
- };
- };
};
};
};
@@ -104,15 +131,27 @@ in {
nodev = {
"/" = {
fsType = "tmpfs";
- mountOptions = ["defaults" "size=4G" "mode=755"];
+ mountOptions = ["defaults" "size=25%" "mode=0755"];
};
"/tmp" = {
fsType = "tmpfs";
- mountOptions = ["defaults" "size=16G" "mode=755"];
+ mountOptions = ["defaults" "size=50%" "mode=0755"];
+ };
+ "/nix/var/nix/b" = {
+ fsType = "tmpfs";
+ mountOptions = [
+ "defaults"
+ "noswap" # Otherwise, we might run into io-based slowdowns
+ "size=80%"
+ "mode=0755"
+ ];
};
};
};
fileSystems = {
+ "/nix" = {
+ neededForBoot = true;
+ };
"/srv" = {
neededForBoot = true;
};
@@ -120,23 +159,14 @@ in {
neededForBoot = true;
};
};
- swapDevices = [
- #{
- # device = "/swap/swapfile";
- # priority = 1; # lower than zramSwap, just in case
- # # size = 2048; # TODO: can nixos create a btrfs swapfile correctly?
- #}
- ];
zramSwap = {
enable = true;
priority = 10; # needs to be higher than hardware-swap
};
boot = {
kernelParams = [
- "resume_offset=${cfg.swap.resumeOffset}"
"zswap.enabled=0" # zswap and zram are not really compatible
];
- resumeDevice = "/dev/disk/by-uuid/${cfg.swap.uuid}";
};
};
}