From 6e67da9c6f3a4017db9ff0c1a557fc1d32c177ee Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Sat, 27 Jul 2024 11:49:39 +0200 Subject: [PATCH] pinwheel: Automatically garbage collect generations --- hosts/pinwheel/modules/boot/default.nix | 42 +++++++++++++++++-------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/hosts/pinwheel/modules/boot/default.nix b/hosts/pinwheel/modules/boot/default.nix index b066383..861db08 100644 --- a/hosts/pinwheel/modules/boot/default.nix +++ b/hosts/pinwheel/modules/boot/default.nix @@ -1,21 +1,37 @@ -{ pkgs, ... }: +{ inputs, pkgs, config, ... }: { - boot = { - kernelPackages = pkgs.linuxPackages_latest; + imports = [ inputs.nix-gc-env.nixosModules.default ]; - kernel = { - sysctl = { - "fs.inotify.max_user_instances" = 1024; # default: 128 + config = { + nix.gc = { + automatic = true; + dates = "weekly"; + + # `delete_generations` added by nix-gc-env + delete_generations = "+${builtins.toString config.boot.loader.systemd-boot.configurationLimit}"; + }; + + boot = { + kernelPackages = pkgs.linuxPackages_latest; + + kernel = { + sysctl = { + "fs.inotify.max_user_instances" = 1024; # default: 128 + }; }; - }; - loader = { - systemd-boot.enable = true; - efi.canTouchEfiVariables = true; - }; + loader = { + systemd-boot = { + enable = true; + configurationLimit = 10; + }; - initrd.secrets = { - "/crypto_keyfile.bin" = null; + efi.canTouchEfiVariables = true; + }; + + initrd.secrets = { + "/crypto_keyfile.bin" = null; + }; }; }; }