diff options
Diffstat (limited to 'modules/by-name/di/disks')
| -rw-r--r-- | modules/by-name/di/disks/module.nix | 85 |
1 files changed, 49 insertions, 36 deletions
diff --git a/modules/by-name/di/disks/module.nix b/modules/by-name/di/disks/module.nix index 3e9d4614..ed5c939a 100644 --- a/modules/by-name/di/disks/module.nix +++ b/modules/by-name/di/disks/module.nix @@ -14,10 +14,9 @@ modules, ... }: let - # FIXME: The iso redeploy requires a bigger efi partition <2024-05-12> cfg = config.soispha.disks; defaultMountOptions = [ - "compress=zstd:3" # This saves disk space, at a performance cost + "compress-force=zstd:15" # This saves disk space, at a performance cost "noatime" # should have some performance upsides, and I don't use it anyways "lazytime" # make time changes in memory ]; @@ -34,15 +33,10 @@ 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)"; }; }; }; @@ -54,6 +48,12 @@ in { 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 = { @@ -61,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; @@ -90,21 +113,17 @@ in { "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"; - }; - }; }; }; }; @@ -130,6 +149,9 @@ in { }; }; fileSystems = { + "/nix" = { + neededForBoot = true; + }; "/srv" = { neededForBoot = true; }; @@ -137,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}"; }; }; } |
