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 3a5ff9a68c was
only concerned with silencing warnings, so the addition of the "pre.*"
suffix into stateVersion was probably unintentional.
This commit is contained in:
tilpner 2024-09-08 13:05:28 +02:00 committed by Alexander Foremny
parent d665bd5ee0
commit 0c24185366
3 changed files with 3 additions and 3 deletions

View File

@ -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;

View File

@ -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 ];

View File

@ -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 {