Merge pull request #63766 from NixOS/backport-systemd-boot-configurationLimit

Add configurationLimit to systemd-boot to prevent running out of disk…
This commit is contained in:
Domen Kožar
2019-07-26 14:43:45 +02:00
committed by GitHub
2 changed files with 18 additions and 1 deletions

View File

@@ -124,7 +124,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$")

View File

@@ -22,6 +22,8 @@ let
editor = if cfg.editor then "True" else "False";
configurationLimit = if cfg.configurationLimit == null then 0 else cfg.configurationLimit;
inherit (cfg) consoleMode;
inherit (efi) efiSysMountPoint canTouchEfiVariables;
@@ -55,6 +57,19 @@ in {
'';
};
configurationLimit = mkOption {
default = null;
example = 120;
type = types.nullOr types.int;
description = ''
Maximum number of latest generations in the boot menu.
Useful to prevent boot partition running out of disk space.
<literal>null</literal> means no limit i.e. all generations
that were not garbage collected yet.
'';
};
consoleMode = mkOption {
default = "keep";