From 992a479496723a4bd4c0376ea5134bb408176d98 Mon Sep 17 00:00:00 2001 From: Andre Date: Sat, 7 Dec 2024 12:46:48 -0500 Subject: [PATCH] Nix: tweak retention options and defaults --- modules/nixos/default.nix | 2 +- modules/nixos/services/autoupgrade/default.nix | 2 +- modules/nixos/system/nix/default.nix | 18 ++++++++---------- systems/x86_64-linux/Hevana/default.nix | 3 --- systems/x86_64-linux/Khanda/default.nix | 3 --- systems/x86_64-linux/Shura/default.nix | 4 ++-- 6 files changed, 12 insertions(+), 20 deletions(-) diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index dcd427f..b3cd4fd 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -16,7 +16,7 @@ ]; # Install the nos helper script - nixos-operations-script.enable = true; + nix.nixos-operations-script.enable = true; }; programs = { diff --git a/modules/nixos/services/autoupgrade/default.nix b/modules/nixos/services/autoupgrade/default.nix index 4b0cf54..1e2470d 100644 --- a/modules/nixos/services/autoupgrade/default.nix +++ b/modules/nixos/services/autoupgrade/default.nix @@ -59,7 +59,7 @@ in ]; # Deploy update script - ${namespace}.nixos-operations-script.enable = true; + ${namespace}.nix.nixos-operations-script.enable = true; # Pull and apply updates. systemd = { diff --git a/modules/nixos/system/nix/default.nix b/modules/nixos/system/nix/default.nix index c86c41f..d957848 100644 --- a/modules/nixos/system/nix/default.nix +++ b/modules/nixos/system/nix/default.nix @@ -10,22 +10,20 @@ }: let - cfg = config.${namespace}; + cfg = config.${namespace}.nix; nixos-operations-script = pkgs.writeShellScriptBin "nixos-operations-script" ( builtins.readFile (lib.snowfall.fs.get-file "bin/nixos-operations-script.sh") ); in { - options = { - ${namespace} = { - retentionPeriod = lib.mkOption { - description = "How long to retain NixOS generations. Defaults to one month."; - type = lib.types.str; - default = "monthly"; - }; - nixos-operations-script.enable = lib.mkEnableOption "Installs the nos (nixos-operations-script) helper script."; + options.${namespace}.nix = { + retention = lib.mkOption { + description = "How long to retain NixOS generations. Defaults to two weeks."; + type = lib.types.str; + default = "14d"; }; + nixos-operations-script.enable = lib.mkEnableOption "Installs the nos (nixos-operations-script) helper script."; }; config = lib.mkMerge [ { @@ -82,7 +80,7 @@ in gc = { automatic = true; dates = "weekly"; - options = "--delete-older-than ${cfg.retentionPeriod}"; + options = "--delete-older-than ${cfg.retention}"; persistent = true; randomizedDelaySec = "1hour"; }; diff --git a/systems/x86_64-linux/Hevana/default.nix b/systems/x86_64-linux/Hevana/default.nix index d5a3c06..3463f8c 100644 --- a/systems/x86_64-linux/Hevana/default.nix +++ b/systems/x86_64-linux/Hevana/default.nix @@ -114,9 +114,6 @@ in mailAddr = config.secrets.users.aires.email; }; - # Change how long old generations are kept for. - retentionPeriod = "30d"; - services = { acme = { enable = true; diff --git a/systems/x86_64-linux/Khanda/default.nix b/systems/x86_64-linux/Khanda/default.nix index 2cc6312..d7e71dd 100644 --- a/systems/x86_64-linux/Khanda/default.nix +++ b/systems/x86_64-linux/Khanda/default.nix @@ -41,9 +41,6 @@ in # Enable support for primary RAID array (just in case) raid.storage.enable = true; - # Change how long old generations are kept for. - retentionPeriod = "14d"; - services = { autoUpgrade = { enable = true; diff --git a/systems/x86_64-linux/Shura/default.nix b/systems/x86_64-linux/Shura/default.nix index b7e3ca1..72b19f8 100644 --- a/systems/x86_64-linux/Shura/default.nix +++ b/systems/x86_64-linux/Shura/default.nix @@ -55,8 +55,8 @@ in # Enable support for primary RAID array (just in case) raid.storage.enable = true; - # Keep old generations for two weeks. - retentionPeriod = "14d"; + # Keep one week of generations. + nix.retention = "7d"; powerManagement.enable = true;