feat: configure to only keep 3 configurations/gens

This commit is contained in:
Jet Pham 2026-03-08 19:04:38 -07:00
parent f5b62c0053
commit 23b2ac9a33
No known key found for this signature in database

View file

@ -4,6 +4,7 @@
imports = [ ./hardware-configuration.nix ]; imports = [ ./hardware-configuration.nix ];
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
boot.loader.systemd-boot.configurationLimit = 3;
boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
boot.loader.timeout = 0; boot.loader.timeout = 0;
@ -144,10 +145,16 @@
}; };
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
nix.settings.experimental-features = [ nix.settings = {
"nix-command" experimental-features = [
"flakes" "nix-command"
]; "flakes"
];
auto-optimise-store = true;
max-jobs = "auto";
cores = 0;
build-users-group = "nixbld";
};
# Framework-specific services # Framework-specific services
# Enable fwupd for BIOS updates (distributed through LVFS) # Enable fwupd for BIOS updates (distributed through LVFS)
@ -156,19 +163,22 @@
# Enable periodic TRIM for NVMe/SSD health # Enable periodic TRIM for NVMe/SSD health
services.fstrim.enable = true; services.fstrim.enable = true;
# Enable automatic garbage collection to prevent old generations from slowing boot # Keep only last 10 generations, GC everything else (daily)
nix.gc = { systemd.services.nix-cleanup = {
automatic = true; description = "Nix generation cleanup and garbage collection";
dates = "daily"; serviceConfig.Type = "oneshot";
options = "--delete-older-than 7d"; script = ''
${pkgs.nix}/bin/nix-env --delete-generations +3 -p /nix/var/nix/profiles/system
${pkgs.nix}/bin/nix-env --delete-generations +3 -p /nix/var/nix/profiles/per-user/jet/home-manager || true
${pkgs.nix}/bin/nix-store --gc
'';
}; };
nix.settings.auto-optimise-store = true; systemd.timers.nix-cleanup = {
nix.optimise.automatic = true; wantedBy = [ "timers.target" ];
timerConfig = {
nix.settings = { OnCalendar = "daily";
max-jobs = "auto"; Persistent = true;
cores = 0; };
build-users-group = "nixbld";
}; };
# Power management for laptop # Power management for laptop