From 0c24185366f374fcf805844857127c2867c32c56 Mon Sep 17 00:00:00 2001 From: tilpner Date: Sun, 8 Sep 2024 13:05:28 +0200 Subject: [PATCH] nixos: set system.stateVersion from the nixpkgs release, not version The nixpkgs/nixos version includes a suffix like "pre-git" or "pre676716.6f16e67b4921", which does not match the conventional "XX.YY" format of system.stateVersion. Unifying the format to "XX.YY" allows for (stricter) validation (see #317858), and the introduction in 3a5ff9a68c9dbb8b707555d44988575b3e9544bf was only concerned with silencing warnings, so the addition of the "pre.*" suffix into stateVersion was probably unintentional. --- flake.nix | 2 +- nixos/release.nix | 2 +- nixos/tests/systemd-machinectl.nix | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index bb7d0d5d4de3..b09b6a5a4a0b 100644 --- a/flake.nix +++ b/flake.nix @@ -64,7 +64,7 @@ boot.loader.grub.enable = false; fileSystems."/".device = "nodev"; # See https://search.nixos.org/options?show=system.stateVersion&query=stateversion - system.stateVersion = lib.versions.majorMinor lib.version; # DON'T do this in real configs! + system.stateVersion = lib.trivial.release; # DON'T do this in real configs! }) ]; }).config.system.build.toplevel; diff --git a/nixos/release.nix b/nixos/release.nix index eeca73ea4c55..8a8c45f8f842 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -49,7 +49,7 @@ let system.nixos.revision = nixpkgs.rev or nixpkgs.shortRev; # At creation time we do not have state yet, so just default to latest. - system.stateVersion = config.system.nixos.version; + system.stateVersion = config.system.nixos.release; }; makeModules = module: rest: [ configuration versionModule module rest ]; diff --git a/nixos/tests/systemd-machinectl.nix b/nixos/tests/systemd-machinectl.nix index 555a8bb43b30..40ea4905ec67 100644 --- a/nixos/tests/systemd-machinectl.nix +++ b/nixos/tests/systemd-machinectl.nix @@ -16,7 +16,7 @@ let imports = [ ../modules/profiles/minimal.nix ]; - system.stateVersion = config.system.nixos.version; + system.stateVersion = config.system.nixos.release; }; containerSystem = (import ../lib/eval-config.nix {