mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/version: validate system.stateVersion
This commit is contained in:
parent
16c2255392
commit
37d08685e8
2 changed files with 24 additions and 0 deletions
|
@ -16,6 +16,7 @@ let
|
|||
toLower
|
||||
optionalString
|
||||
literalExpression
|
||||
match
|
||||
mkRenamedOptionModule
|
||||
mkDefault
|
||||
mkOption
|
||||
|
@ -263,6 +264,27 @@ in
|
|||
|
||||
config = {
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = match "[0-9]{2}\\.[0-9]{2}" config.system.stateVersion != null;
|
||||
message = ''
|
||||
${config.system.stateVersion} is an invalid value for 'system.stateVersion'; it must be in the format "YY.MM",
|
||||
which corresponds to a prior release of NixOS.
|
||||
|
||||
If you want to switch releases or switch to unstable, you should change your channel and/or flake input URLs only.
|
||||
*DO NOT* touch the 'system.stateVersion' option, as it will not help you upgrade.
|
||||
Leave it exactly on the previous value, which is likely the value you had for it when you installed your system.
|
||||
|
||||
If you're unsure which value to set it to, use "${
|
||||
if match "[0-9]{2}\\.[0-9]{2}" options.system.stateVersion.default != null then
|
||||
options.system.stateVersion.default
|
||||
else
|
||||
options.system.nixos.release.default
|
||||
}" as a default.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
system.nixos = {
|
||||
# These defaults are set here rather than up there so that
|
||||
# changing them would not rebuild the manual
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue