From 224a6562a4880195afa5c184e755b8ecaba41536 Mon Sep 17 00:00:00 2001 From: Domen Kožar Date: Sat, 22 Jun 2019 20:10:03 +0200 Subject: Add configurationLimit to systemd-boot to prevent running out of disk space Refs #23926 --- .../system/boot/loader/systemd-boot/systemd-boot-builder.py | 4 +++- .../modules/system/boot/loader/systemd-boot/systemd-boot.nix | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'nixos/modules/system') 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"; -- cgit 1.4.1