From 2fa349ae005e4455d3a2d1bf7bd64463497d1609 Mon Sep 17 00:00:00 2001
From: Florian Sesser <florian@leastauthority.com>
Date: Wed, 18 Dec 2024 14:45:26 +0000
Subject: [PATCH] Configure NixOS to keep fewer old kernels around

Refs #190
---
 morph/lib/issuer-aws.nix | 4 ++++
 nixos/modules/100tb.nix  | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/morph/lib/issuer-aws.nix b/morph/lib/issuer-aws.nix
index 9767e1ad..4c3f866e 100644
--- a/morph/lib/issuer-aws.nix
+++ b/morph/lib/issuer-aws.nix
@@ -19,6 +19,10 @@
   # See https://unix.stackexchange.com/a/554500/81275
   boot.kernelModules = [ "loop" ];
 
+  # NixOS likes to fill up boot partitions with (by default) 100 old kernels.
+  # Keep a (for us) more reasonable number around.
+  boot.loader.grub.configurationLimit = 8;
+
   # Break the tie between AWS and morph for the hostname by forcing the
   # morph-supplied name.  See also
   # <https://github.com/DBCDK/morph/issues/146>.
diff --git a/nixos/modules/100tb.nix b/nixos/modules/100tb.nix
index 997e82e1..bd8a11c8 100644
--- a/nixos/modules/100tb.nix
+++ b/nixos/modules/100tb.nix
@@ -105,6 +105,9 @@ in {
   { boot.loader.grub.enable = true;
     boot.loader.grub.device = if cfg.grubDeviceID == "nodev"  then "nodev" else "/dev/disk/by-id/${cfg.grubDeviceID}";
     boot.loader.timeout = 10;
+    # NixOS likes to fill up boot partitions with (by default) 100 old kernels.
+    # Keep a (for us) more reasonable number around.
+    boot.loader.grub.configurationLimit = 8;
     networking.firewall.enable = false;
 
     networking.hostId = cfg.hostId;
-- 
GitLab