From a0a9cef2a6ec43c4e5d78a02192c80fcc3489676 Mon Sep 17 00:00:00 2001 From: pinpox Date: Wed, 2 Jul 2025 09:46:06 +0200 Subject: [PATCH] Add state-version nixos option This reverts commit 695574988e157e72d5b07cee009261c1a7837580. --- checks/flake-module.nix | 1 + clanModules/state-version/roles/default.nix | 9 ++++++--- clanServices/state-version/default.nix | 10 ++++++++++ clanServices/state-version/tests/vm/default.nix | 5 +++-- nixosModules/clanCore/default.nix | 2 +- .../state-version/tests/sops/users/admin/key.json | 4 ++++ .../per-machine/server/state-version/version/value | 1 + pkgs/clan-cli/clan_lib/tests/test_create.py | 12 +----------- templates/clan/new-clan/modules/shared.nix | 1 - 9 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 nixosModules/clanCore/state-version/tests/sops/users/admin/key.json create mode 100644 nixosModules/clanCore/state-version/tests/vars/per-machine/server/state-version/version/value diff --git a/checks/flake-module.nix b/checks/flake-module.nix index a6f4a0eff..8cb587f45 100644 --- a/checks/flake-module.nix +++ b/checks/flake-module.nix @@ -22,6 +22,7 @@ in imports = filter pathExists [ ./backups/flake-module.nix ../nixosModules/clanCore/machine-id/tests/flake-module.nix + ../nixosModules/clanCore/state-version/tests/flake-module.nix ./devshell/flake-module.nix ./flash/flake-module.nix ./impure/flake-module.nix diff --git a/clanModules/state-version/roles/default.nix b/clanModules/state-version/roles/default.nix index a136e8432..b164ca90a 100644 --- a/clanModules/state-version/roles/default.nix +++ b/clanModules/state-version/roles/default.nix @@ -5,9 +5,12 @@ in { warnings = [ - "The clan.state-version module is deprecated and will be removed on 2025-07-15. - Please migrate to user-maintained configuration or the new equivalent clan services - (https://docs.clan.lol/reference/clanServices)." + '' + The clan.state-version service is deprecated and will be + removed on 2025-07-15 in favor of a nix option. + + Please migrate your configuration to use `clan.core.settings.state-version.enable = true` instead. + '' ]; system.stateVersion = lib.mkDefault (lib.removeSuffix "\n" var.value); diff --git a/clanServices/state-version/default.nix b/clanServices/state-version/default.nix index 34a0575e8..ef7a90fa1 100644 --- a/clanServices/state-version/default.nix +++ b/clanServices/state-version/default.nix @@ -20,6 +20,16 @@ var = config.clan.core.vars.generators.state-version.files.version or { }; in { + + warnings = [ + '' + The clan.state-version service is deprecated and will be + removed on 2025-07-15 in favor of a nix option. + + Please migrate your configuration to use `clan.core.settings.state-version.enable = true` instead. + '' + ]; + system.stateVersion = lib.mkDefault (lib.removeSuffix "\n" var.value); clan.core.vars.generators.state-version = { diff --git a/clanServices/state-version/tests/vm/default.nix b/clanServices/state-version/tests/vm/default.nix index efd4a6f14..2c9a81aeb 100644 --- a/clanServices/state-version/tests/vm/default.nix +++ b/clanServices/state-version/tests/vm/default.nix @@ -1,5 +1,6 @@ +{ lib, ... }: { - name = "state-version"; + name = "service-state-version"; clan = { directory = ./.; @@ -15,7 +16,7 @@ nodes.server = { }; - testScript = '' + testScript = lib.mkDefault '' start_all() ''; } diff --git a/nixosModules/clanCore/default.nix b/nixosModules/clanCore/default.nix index 5ada42fd8..891b7cec5 100644 --- a/nixosModules/clanCore/default.nix +++ b/nixosModules/clanCore/default.nix @@ -13,13 +13,13 @@ ./options.nix ./outputs.nix ./sops.nix - ./state-version/default.nix ./vars ] ++ lib.optionals (_class == "nixos") [ ./nixos-facter.nix ./vm.nix ./machine-id + ./state-version ./wayland-proxy-virtwl.nix ./zerotier ./zfs.nix diff --git a/nixosModules/clanCore/state-version/tests/sops/users/admin/key.json b/nixosModules/clanCore/state-version/tests/sops/users/admin/key.json new file mode 100644 index 000000000..e408aa96b --- /dev/null +++ b/nixosModules/clanCore/state-version/tests/sops/users/admin/key.json @@ -0,0 +1,4 @@ +{ + "publickey": "age1qm0p4vf9jvcnn43s6l4prk8zn6cx0ep9gzvevxecv729xz540v8qa742eg", + "type": "age" +} diff --git a/nixosModules/clanCore/state-version/tests/vars/per-machine/server/state-version/version/value b/nixosModules/clanCore/state-version/tests/vars/per-machine/server/state-version/version/value new file mode 100644 index 000000000..115ab7a6a --- /dev/null +++ b/nixosModules/clanCore/state-version/tests/vars/per-machine/server/state-version/version/value @@ -0,0 +1 @@ +25.11 \ No newline at end of file diff --git a/pkgs/clan-cli/clan_lib/tests/test_create.py b/pkgs/clan-cli/clan_lib/tests/test_create.py index 7090e8b85..29b460a19 100644 --- a/pkgs/clan-cli/clan_lib/tests/test_create.py +++ b/pkgs/clan-cli/clan_lib/tests/test_create.py @@ -64,17 +64,7 @@ def create_base_inventory(ssh_keys_pairs: list[SSHKeyPair]) -> InventoryWrapper: ssh_keys.append(InvSSHKeyEntry(f"user_{num}", ssh_key.public.read_text())) """Create the base inventory structure.""" - legacy_services: dict[str, Any] = { - "state-version": { - "someid": { - "roles": { - "default": { - "tags": ["all"], - } - } - } - }, - } + legacy_services: dict[str, Any] = {} instances = InventoryInstancesType( { diff --git a/templates/clan/new-clan/modules/shared.nix b/templates/clan/new-clan/modules/shared.nix index 23f8a3fb3..d6dc92a85 100644 --- a/templates/clan/new-clan/modules/shared.nix +++ b/templates/clan/new-clan/modules/shared.nix @@ -12,7 +12,6 @@ # Set a root password clan-core.clanModules.root-password clan-core.clanModules.user-password - clan-core.clanModules.state-version # You can access other flakes imported in your flake via `self` like this: # self.inputs.nix-index-database.nixosModules.nix-index