summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorDomen Kožar <domen@dev.si>2019-06-22 20:10:03 +0200
committerDomen Kožar <domen@dev.si>2019-06-22 20:11:11 +0200
commit224a6562a4880195afa5c184e755b8ecaba41536 (patch)
tree216e56ac04155ede06a66192fcc3b4332602cde7 /nixos
parent8b7c42032ea563d545712272cfa7d10fd9b60681 (diff)
downloadnixpkgs-224a6562a4880195afa5c184e755b8ecaba41536.tar
nixpkgs-224a6562a4880195afa5c184e755b8ecaba41536.tar.gz
nixpkgs-224a6562a4880195afa5c184e755b8ecaba41536.tar.bz2
nixpkgs-224a6562a4880195afa5c184e755b8ecaba41536.tar.lz
nixpkgs-224a6562a4880195afa5c184e755b8ecaba41536.tar.xz
nixpkgs-224a6562a4880195afa5c184e755b8ecaba41536.tar.zst
nixpkgs-224a6562a4880195afa5c184e755b8ecaba41536.zip
Add configurationLimit to systemd-boot to prevent running out of disk space
Refs #23926
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py4
-rw-r--r--nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix12
2 files changed, 14 insertions, 2 deletions
diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
index ebe37ca10a2..f48a085ce57 100644
--- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
+++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
@@ -133,7 +133,9 @@ def get_generations(profile=None):
         universal_newlines=True)
     gen_lines = gen_list.split('\n')
     gen_lines.pop()
-    return [ (profile, int(line.split()[0])) for line in gen_lines ]
+
+    configurationLimit = @configurationLimit@
+    return [ (profile, int(line.split()[0])) for line in gen_lines ][-configurationLimit:]
 
 def remove_old_entries(gens):
     rex_profile = re.compile("^@efiSysMountPoint@/loader/entries/nixos-(.*)-generation-.*\.conf$")
diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
index 3e39dc5dd39..910a602c61d 100644
--- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
+++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
@@ -22,7 +22,7 @@ let
 
     editor = if cfg.editor then "True" else "False";
 
-    inherit (cfg) consoleMode;
+    inherit (cfg) consoleMode configurationLimit;
 
     inherit (efi) efiSysMountPoint canTouchEfiVariables;
 
@@ -57,6 +57,16 @@ in {
       '';
     };
 
+    configurationLimit = mkOption {
+      default = 100;
+      example = 120;
+      type = types.int;
+      description = ''
+        Maximum of configurations in boot menu. Otherwise boot partition could
+        run out of disk space.
+      '';
+    };
+
     consoleMode = mkOption {
       default = "keep";