From 66332c1ae68d631ccfee733e35824e6622f7abe6 Mon Sep 17 00:00:00 2001 From: Pablo Ovelleiro Corral Date: Mon, 24 Feb 2025 13:10:17 +0100 Subject: [PATCH] Add auto-upgrade module --- clanModules/auto-upgrade/README.md | 8 ++++++++ clanModules/auto-upgrade/roles/default.nix | 24 ++++++++++++++++++++++ clanModules/flake-module.nix | 1 + docs/mkdocs.yml | 1 + 4 files changed, 34 insertions(+) create mode 100644 clanModules/auto-upgrade/README.md create mode 100644 clanModules/auto-upgrade/roles/default.nix diff --git a/clanModules/auto-upgrade/README.md b/clanModules/auto-upgrade/README.md new file mode 100644 index 000000000..49b33c18b --- /dev/null +++ b/clanModules/auto-upgrade/README.md @@ -0,0 +1,8 @@ +--- +description = "Set up automatic upgrades" +categories = ["System"] +features = [ "inventory" ] +--- + +Whether to periodically upgrade NixOS to the latest version. If enabled, a +systemd timer will run `nixos-rebuild switch --upgrade` once a day. diff --git a/clanModules/auto-upgrade/roles/default.nix b/clanModules/auto-upgrade/roles/default.nix new file mode 100644 index 000000000..b8b883fe7 --- /dev/null +++ b/clanModules/auto-upgrade/roles/default.nix @@ -0,0 +1,24 @@ +{ + config, + lib, + ... +}: +let + cfg = config.clan.autoUpgrade; +in +{ + options.clan.autoUpgrade = { + flake = lib.mkOption { + type = lib.types.str; + description = "Flake reference"; + }; + }; + config = { + system.autoUpgrade = { + inherit (cfg.clan.autoUpgrade) flake; + enable = true; + dates = "02:00"; + randomizedDelaySec = "45min"; + }; + }; +} diff --git a/clanModules/flake-module.nix b/clanModules/flake-module.nix index 706e3515f..8fbc13244 100644 --- a/clanModules/flake-module.nix +++ b/clanModules/flake-module.nix @@ -9,6 +9,7 @@ in # only import available files, as this allows to filter the files for tests. flake.clanModules = filterAttrs (_name: pathExists) { admin = ./admin; + auto-upgrade = ./auto-upgrade; borgbackup = ./borgbackup; borgbackup-static = ./borgbackup-static; deltachat = ./deltachat; diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index f99cba943..dc44e9884 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -108,6 +108,7 @@ nav: - reference/clanModules/thelounge.md - reference/clanModules/trusted-nix-caches.md - reference/clanModules/user-password.md + - reference/clanModules/auto-upgrade.md - reference/clanModules/vaultwarden.md - reference/clanModules/xfce.md - reference/clanModules/zerotier-static-peers.md