From 7dd587e56cc1248ffa1067b6ac634ed5e8f0c174 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Sun, 18 Aug 2024 14:38:02 +0200 Subject: [PATCH] backwards: Automatically garbage collect generations --- hosts/backwards/modules/boot/default.nix | 40 +++++++++++++++++++----- hosts/backwards/modules/default.nix | 2 ++ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/hosts/backwards/modules/boot/default.nix b/hosts/backwards/modules/boot/default.nix index 464d4ba..2b44506 100644 --- a/hosts/backwards/modules/boot/default.nix +++ b/hosts/backwards/modules/boot/default.nix @@ -1,12 +1,38 @@ -{ ... }: +{ inputs, lib, config, ... }: +let + configurationLimit = config.mod.gc.configurationLimit; +in { - boot = { - loader = { - systemd-boot = { - enable = true; - }; + imports = [ inputs.nix-gc-env.nixosModules.default ]; - efi.canTouchEfiVariables = true; + options = { + mod.gc = { + configurationLimit = lib.mkOption { + type = lib.types.int; + default = 10; + description = "number of configuration generations to keep"; + }; + }; + }; + + config = { + nix.gc = { + automatic = true; + dates = "weekly"; + + # `delete_generations` added by nix-gc-env + delete_generations = "+${builtins.toString configurationLimit}"; + }; + + boot = { + loader = { + systemd-boot = { + enable = true; + inherit configurationLimit; + }; + + efi.canTouchEfiVariables = true; + }; }; }; } diff --git a/hosts/backwards/modules/default.nix b/hosts/backwards/modules/default.nix index 0e0fc0e..3cf51b3 100644 --- a/hosts/backwards/modules/default.nix +++ b/hosts/backwards/modules/default.nix @@ -8,6 +8,8 @@ in config = { mod = { + gc.configurationLimit = 10; + ssh.enable = true; git.enable = true; };