diff --git a/checks/flake-module.nix b/checks/flake-module.nix index 7aec75d36..0cffe80f3 100644 --- a/checks/flake-module.nix +++ b/checks/flake-module.nix @@ -10,6 +10,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/flake-module.nix b/clanModules/flake-module.nix index 54bcfc4d1..2cbdd6744 100644 --- a/clanModules/flake-module.nix +++ b/clanModules/flake-module.nix @@ -33,7 +33,6 @@ in root-password = ./root-password; single-disk = ./single-disk; sshd = ./sshd; - state-version = ./state-version; static-hosts = ./static-hosts; sunshine = ./sunshine; syncthing = ./syncthing; diff --git a/clanModules/state-version/README.md b/clanModules/state-version/README.md deleted file mode 100644 index f8544f0de..000000000 --- a/clanModules/state-version/README.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -description = "Automatically generate the state version of the nixos installation." -features = [ "inventory", "deprecated" ] ---- - -This module generates the `system.stateVersion` of the nixos installation automatically. - -Options: [system.stateVersion](https://search.nixos.org/options?channel=unstable&show=system.stateVersion&from=0&size=50&sort=relevance&type=packages&query=stateVersion) - -Migration: -If you are already setting `system.stateVersion`, then import the module and then either let the automatic generation happen, or trigger the generation manually for the machine. The module will take the specified version, if one is already supplied through the config. -To manually generate the version for a specified machine run: - -``` -clan vars generate [MACHINE] -``` - -If the setting was already set you can then remove `system.stateVersion` from your machine configuration. For new machines, just import the module. diff --git a/clanModules/state-version/default.nix b/clanModules/state-version/default.nix deleted file mode 100644 index ed6af3368..000000000 --- a/clanModules/state-version/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -# Dont import this file -# It is only here for backwards compatibility. -# Dont author new modules with this file. -{ - imports = [ ./roles/default.nix ]; -} diff --git a/clanModules/state-version/roles/default.nix b/clanModules/state-version/roles/default.nix deleted file mode 100644 index a136e8432..000000000 --- a/clanModules/state-version/roles/default.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ config, lib, ... }: -let - var = config.clan.core.vars.generators.state-version.files.version or { }; -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)." - ]; - - system.stateVersion = lib.mkDefault (lib.removeSuffix "\n" var.value); - - clan.core.vars.generators.state-version = { - files.version = { - secret = false; - value = lib.mkDefault config.system.nixos.release; - }; - runtimeInputs = [ ]; - script = '' - echo -n ${config.system.stateVersion} > "$out"/version - ''; - }; -} diff --git a/clanServices/state-version/README.md b/clanServices/state-version/README.md deleted file mode 100644 index c55063b66..000000000 --- a/clanServices/state-version/README.md +++ /dev/null @@ -1,37 +0,0 @@ -This service generates the `system.stateVersion` of the nixos installation -automatically. - -Possible values: -[system.stateVersion](https://search.nixos.org/options?channel=unstable&show=system.stateVersion&from=0&size=50&sort=relevance&type=packages&query=stateVersion) - -## Usage - -The following configuration will set `stateVersion` for all machines: - -``` -inventory.instances = { - state-version = { - module = { - name = "state-version"; - input = "clan"; - }; - roles.default.tags.all = { }; - }; -``` - -## Migration - -If you are already setting `system.stateVersion`, either let the automatic -generation happen, or trigger the generation manually for the machine. The -service will take the specified version, if one is already supplied through the -config. - -To manually generate the version for a specified machine run: - -``` -clan vars generate [MACHINE] -``` - -If the setting was already set, you can then remove `system.stateVersion` from -your machine configuration. For new machines, just import the service as shown -above. diff --git a/clanServices/state-version/default.nix b/clanServices/state-version/default.nix deleted file mode 100644 index 34a0575e8..000000000 --- a/clanServices/state-version/default.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ ... }: -{ - _class = "clan.service"; - manifest.name = "clan-core/state-version"; - manifest.description = "Automatically generate the state version of the nixos installation."; - manifest.categories = [ "System" ]; - - roles.default = { - - perInstance = - { ... }: - { - nixosModule = - { - config, - lib, - ... - }: - let - var = config.clan.core.vars.generators.state-version.files.version or { }; - in - { - system.stateVersion = lib.mkDefault (lib.removeSuffix "\n" var.value); - - clan.core.vars.generators.state-version = { - files.version = { - secret = false; - value = lib.mkDefault config.system.nixos.release; - }; - runtimeInputs = [ ]; - script = '' - echo -n ${config.system.stateVersion} > "$out"/version - ''; - }; - }; - }; - }; - -} diff --git a/clanServices/state-version/flake-module.nix b/clanServices/state-version/flake-module.nix deleted file mode 100644 index c4ff9d633..000000000 --- a/clanServices/state-version/flake-module.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ lib, ... }: -let - module = lib.modules.importApply ./default.nix { }; -in -{ - clan.modules.state-version = module; - perSystem = - { ... }: - { - clan.nixosTests.state-version = { - imports = [ ./tests/vm/default.nix ]; - - clan.modules."@clan/state-version" = module; - }; - }; -} diff --git a/clanServices/state-version/tests/vm/default.nix b/clanServices/state-version/tests/vm/default.nix deleted file mode 100644 index efd4a6f14..000000000 --- a/clanServices/state-version/tests/vm/default.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ - name = "state-version"; - - clan = { - directory = ./.; - inventory = { - machines.server = { }; - instances.default = { - module.name = "@clan/state-version"; - module.input = "self"; - roles.default.machines."server" = { }; - }; - }; - }; - - nodes.server = { }; - - testScript = '' - start_all() - ''; -} diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index ddf1d0810..08f9db0c7 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -91,7 +91,6 @@ nav: - reference/clanServices/mycelium.md - reference/clanServices/packages.md - reference/clanServices/sshd.md - - reference/clanServices/state-version.md - reference/clanServices/trusted-nix-caches.md - reference/clanServices/users.md - reference/clanServices/wifi.md @@ -126,7 +125,6 @@ nav: - reference/clanModules/root-password.md - reference/clanModules/single-disk.md - reference/clanModules/sshd.md - - reference/clanModules/state-version.md - reference/clanModules/static-hosts.md - reference/clanModules/sunshine.md - reference/clanModules/syncthing-static-peers.md diff --git a/nixosModules/clanCore/default.nix b/nixosModules/clanCore/default.nix index 2b2c3990b..891b7cec5 100644 --- a/nixosModules/clanCore/default.nix +++ b/nixosModules/clanCore/default.nix @@ -19,6 +19,7 @@ ./nixos-facter.nix ./vm.nix ./machine-id + ./state-version ./wayland-proxy-virtwl.nix ./zerotier ./zfs.nix diff --git a/nixosModules/clanCore/state-version/default.nix b/nixosModules/clanCore/state-version/default.nix new file mode 100644 index 000000000..44d0aabac --- /dev/null +++ b/nixosModules/clanCore/state-version/default.nix @@ -0,0 +1,31 @@ +{ + lib, + config, + ... +}: +let + var = config.clan.core.vars.generators.state-version.files.version or { }; +in +{ + options.clan.core.settings.state-version = { + enable = lib.mkEnableOption "automatic state-version generation. + + The option will take the specified version, if one is already supplied through + the config or generate one if not. + "; + }; + + config = lib.mkIf (config.clan.core.settings.state-version.enable) { + system.stateVersion = lib.mkDefault (lib.removeSuffix "\n" var.value); + clan.core.vars.generators.state-version = { + files.version = { + secret = false; + value = lib.mkDefault config.system.nixos.release; + }; + runtimeInputs = [ ]; + script = '' + echo -n ${config.system.stateVersion} > "$out"/version + ''; + }; + }; +} diff --git a/nixosModules/clanCore/state-version/tests/flake-module.nix b/nixosModules/clanCore/state-version/tests/flake-module.nix new file mode 100644 index 000000000..f5e65fa71 --- /dev/null +++ b/nixosModules/clanCore/state-version/tests/flake-module.nix @@ -0,0 +1,39 @@ +{ ... }: +{ + perSystem = + { ... }: + { + clan.nixosTests.state-version = { + + name = "state-version"; + + clan = { + directory = ./.; + + # Workaround until we can use nodes.server = { }; + modules."@clan/importer" = ../../../../clanServices/importer; + + inventory = { + machines.server = { }; + instances.importer = { + module.name = "@clan/importer"; + module.input = "self"; + roles.default.tags.all = { }; + roles.default.extraModules = [ + { + clan.core.settings.state-version.enable = true; + } + ]; + }; + }; + }; + + # TODO: Broken. Use instead of importer after fixing. + # nodes.server = { }; + + # This is not an actual vm test, this is a workaround to + # generate the needed vars for the eval test. + testScript = ""; + }; + }; +} diff --git a/clanServices/state-version/tests/vm/sops/users/admin/key.json b/nixosModules/clanCore/state-version/tests/sops/users/admin/key.json similarity index 100% rename from clanServices/state-version/tests/vm/sops/users/admin/key.json rename to nixosModules/clanCore/state-version/tests/sops/users/admin/key.json diff --git a/clanServices/state-version/tests/vm/vars/per-machine/server/state-version/version/value b/nixosModules/clanCore/state-version/tests/vars/per-machine/server/state-version/version/value similarity index 100% rename from clanServices/state-version/tests/vm/vars/per-machine/server/state-version/version/value rename to nixosModules/clanCore/state-version/tests/vars/per-machine/server/state-version/version/value diff --git a/pkgs/clan-cli/clan_lib/tests/test_create.py b/pkgs/clan-cli/clan_lib/tests/test_create.py index 261e84bf1..82fa99407 100644 --- a/pkgs/clan-cli/clan_lib/tests/test_create.py +++ b/pkgs/clan-cli/clan_lib/tests/test_create.py @@ -63,17 +63,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