From e27605d3a027e70ae9d4a8f28f4c6ee26b2140a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 14 Feb 2025 12:13:36 +0700 Subject: [PATCH] fix system.stateVersion --- checks/lib/test-base.nix | 19 +++++++++++-------- lib/eval-clan-modules/default.nix | 13 ++++++++----- pkgs/clan-cli/tests/machines/vm1/default.nix | 4 ++-- .../machines/vm_with_secrets/default.nix | 4 ++-- .../machines/vm_without_secrets/default.nix | 4 ++-- .../tests/test_flake_with_core/flake.nix | 8 ++++---- .../test_flake_with_core_and_pass/flake.nix | 4 ++-- pkgs/installer/flake-module.nix | 2 +- .../flash-installer/configuration.nix | 2 +- templates/flake-module.nix | 4 ++-- 10 files changed, 35 insertions(+), 29 deletions(-) diff --git a/checks/lib/test-base.nix b/checks/lib/test-base.nix index 74570c3df..858f6a34c 100644 --- a/checks/lib/test-base.nix +++ b/checks/lib/test-base.nix @@ -7,14 +7,17 @@ in (nixos-lib.runTest { hostPkgs = pkgs; # speed-up evaluation - defaults = { - imports = [ - ./minify.nix - ]; - documentation.enable = lib.mkDefault false; - nix.settings.min-free = 0; - system.stateVersion = lib.version; - }; + defaults = ( + { config, ... }: + { + imports = [ + ./minify.nix + ]; + documentation.enable = lib.mkDefault false; + nix.settings.min-free = 0; + system.stateVersion = config.system.nixos.release; + } + ); # to accept external dependencies such as disko node.specialArgs.self = self; diff --git a/lib/eval-clan-modules/default.nix b/lib/eval-clan-modules/default.nix index 1fd93e042..d11dd4365 100644 --- a/lib/eval-clan-modules/default.nix +++ b/lib/eval-clan-modules/default.nix @@ -6,11 +6,14 @@ let baseModule = { imports = (import (pkgs.path + "/nixos/modules/module-list.nix")) ++ [ - { - nixpkgs.pkgs = pkgs; - clan.core.name = "dummy"; - system.stateVersion = lib.version; - } + ( + { config, ... }: + { + nixpkgs.pkgs = pkgs; + clan.core.name = "dummy"; + system.stateVersion = config.system.nixos.release; + } + ) ]; }; diff --git a/pkgs/clan-cli/tests/machines/vm1/default.nix b/pkgs/clan-cli/tests/machines/vm1/default.nix index 8c4b81e18..4143da55a 100644 --- a/pkgs/clan-cli/tests/machines/vm1/default.nix +++ b/pkgs/clan-cli/tests/machines/vm1/default.nix @@ -1,7 +1,7 @@ -{ lib, ... }: +{ config, ... }: { clan.core.networking.targetHost = "__CLAN_TARGET_ADDRESS__"; - system.stateVersion = lib.version; + system.stateVersion = config.system.nixos.release; sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__"; clan.core.facts.secretUploadDirectory = "__CLAN_SOPS_KEY_DIR__"; clan.virtualisation.graphics = false; diff --git a/pkgs/clan-cli/tests/machines/vm_with_secrets/default.nix b/pkgs/clan-cli/tests/machines/vm_with_secrets/default.nix index cd3dd7b83..193a5e847 100644 --- a/pkgs/clan-cli/tests/machines/vm_with_secrets/default.nix +++ b/pkgs/clan-cli/tests/machines/vm_with_secrets/default.nix @@ -1,7 +1,7 @@ -{ lib, ... }: +{ config, ... }: { clan.core.networking.targetHost = "__CLAN_TARGET_ADDRESS__"; - system.stateVersion = lib.version; + system.stateVersion = config.system.nixos.release; sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__"; clan.core.facts.secretUploadDirectory = "__CLAN_SOPS_KEY_DIR__"; clan.virtualisation.graphics = false; diff --git a/pkgs/clan-cli/tests/machines/vm_without_secrets/default.nix b/pkgs/clan-cli/tests/machines/vm_without_secrets/default.nix index 41941cea9..d13b00d86 100644 --- a/pkgs/clan-cli/tests/machines/vm_without_secrets/default.nix +++ b/pkgs/clan-cli/tests/machines/vm_without_secrets/default.nix @@ -1,7 +1,7 @@ -{ lib, ... }: +{ config, ... }: { clan.core.networking.targetHost = "__CLAN_TARGET_ADDRESS__"; - system.stateVersion = lib.version; + system.stateVersion = config.system.nixos.release; clan.virtualisation.graphics = false; networking.useDHCP = false; diff --git a/pkgs/clan-cli/tests/test_flake_with_core/flake.nix b/pkgs/clan-cli/tests/test_flake_with_core/flake.nix index 87f1516fb..16a725699 100644 --- a/pkgs/clan-cli/tests/test_flake_with_core/flake.nix +++ b/pkgs/clan-cli/tests/test_flake_with_core/flake.nix @@ -14,11 +14,11 @@ meta.name = "test_flake_with_core"; machines = { vm1 = - { lib, ... }: + { config, ... }: { nixpkgs.hostPlatform = "x86_64-linux"; clan.core.networking.targetHost = "__CLAN_TARGET_ADDRESS__"; - system.stateVersion = lib.version; + system.stateVersion = config.system.nixos.release; sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__"; clan.core.facts.secretUploadDirectory = "__CLAN_SOPS_KEY_DIR__"; clan.core.sops.defaultGroups = [ "admins" ]; @@ -28,7 +28,7 @@ networking.useDHCP = false; }; vm2 = - { lib, ... }: + { config, ... }: { nixpkgs.hostPlatform = "x86_64-linux"; imports = [ @@ -39,7 +39,7 @@ clan.user-password.user = "alice"; clan.user-password.prompt = false; clan.core.networking.targetHost = "__CLAN_TARGET_ADDRESS__"; - system.stateVersion = lib.version; + system.stateVersion = config.system.nixos.release; sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__"; clan.core.facts.secretUploadDirectory = "__CLAN_SOPS_KEY_DIR__"; clan.core.networking.zerotier.networkId = "82b44b162ec6c013"; diff --git a/pkgs/clan-cli/tests/test_flake_with_core_and_pass/flake.nix b/pkgs/clan-cli/tests/test_flake_with_core_and_pass/flake.nix index a0eb28c0a..03715c891 100644 --- a/pkgs/clan-cli/tests/test_flake_with_core_and_pass/flake.nix +++ b/pkgs/clan-cli/tests/test_flake_with_core_and_pass/flake.nix @@ -13,7 +13,7 @@ meta.name = "test_flake_with_core_and_pass"; machines = { vm1 = - { lib, ... }: + { lib, config, ... }: { imports = [ clan-core.clanModules.sshd @@ -24,7 +24,7 @@ clan.user-password.prompt = false; clan.core.networking.targetHost = "__CLAN_TARGET_ADDRESS__"; - system.stateVersion = lib.version; + system.stateVersion = config.system.nixos.release; clan.core.facts.secretStore = "password-store"; clan.core.facts.secretUploadDirectory = lib.mkForce "__CLAN_SOPS_KEY_DIR__/secrets"; diff --git a/pkgs/installer/flake-module.nix b/pkgs/installer/flake-module.nix index 02eef1146..51a06c30f 100644 --- a/pkgs/installer/flake-module.nix +++ b/pkgs/installer/flake-module.nix @@ -15,7 +15,7 @@ let self.clanModules.trusted-nix-caches ]; - system.stateVersion = config.system.nixos.version; + system.stateVersion = config.system.nixos.release; nixpkgs.pkgs = self.inputs.nixpkgs.legacyPackages.x86_64-linux; boot.loader.grub.efiSupport = lib.mkDefault true; diff --git a/templates/clan/machineTemplates/machines/flash-installer/configuration.nix b/templates/clan/machineTemplates/machines/flash-installer/configuration.nix index 904b0bba4..cdbab6247 100644 --- a/templates/clan/machineTemplates/machines/flash-installer/configuration.nix +++ b/templates/clan/machineTemplates/machines/flash-installer/configuration.nix @@ -14,5 +14,5 @@ ]; nixpkgs.pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; - system.stateVersion = config.system.nixos.version; + system.stateVersion = config.system.nixos.release; } diff --git a/templates/flake-module.nix b/templates/flake-module.nix index 12ebec728..57ce0b610 100644 --- a/templates/flake-module.nix +++ b/templates/flake-module.nix @@ -11,9 +11,9 @@ # TODO: Instead create a machine by calling the API, this wont break in future tests and is much closer to what the user performs cat > $out/machines/testmachine/hardware-configuration.nix << EOF - { lib, ... }: { + { lib, config, ... }: { nixpkgs.hostPlatform = "x86_64-linux"; - system.stateVersion = lib.version; + system.stateVersion = config.system.nixos.release; documentation.enable = false; users.users.root.initialPassword = "fnord23"; boot.loader.grub.devices = lib.mkForce [ "/dev/sda" ];