nixos/version: validate system.stateVersion

This commit is contained in:
éclairevoyant 2025-02-05 22:50:36 -05:00
parent 16c2255392
commit 37d08685e8
No known key found for this signature in database
GPG Key ID: E3813AEAA02DB54B
2 changed files with 24 additions and 0 deletions

View File

@ -437,6 +437,8 @@
- Overriding Wayland compositor is possible using `enableWaylandSession` option, but you might need to take care [`xfce4-session`](https://gitlab.xfce.org/xfce/xfce4-session/-/merge_requests/49), [`dbus-update-activation-environment`](https://github.com/labwc/labwc/blob/eaf11face68ee1f1bcc7ce1498304ca8c108c8ba/src/config/session.c#L234) and [`systemctl --user import-environment`](https://github.com/labwc/labwc/blob/eaf11face68ee1f1bcc7ce1498304ca8c108c8ba/src/config/session.c#L239) on startup.
- For new Xfce installations, default panel layout has [changed](https://gitlab.xfce.org/xfce/xfce4-panel/-/merge_requests/158/diffs) to not include external panel plugins by default. You can still add them yourself using the "Panel Preferences" dialog.
- [`system.stateVersion`](#opt-system.stateVersion) is now validated and must be in the `"YY.MM"` format, ideally corresponding to a prior NixOS release.
- GOverlay has been updated to 1.2, please check the [upstream changelog](https://github.com/benjamimgois/goverlay/releases) for more details.
- [`services.mongodb`](#opt-services.mongodb.enable) is now compatible with the `mongodb-ce` binary package. To make use of it, set [`services.mongodb.package`](#opt-services.mongodb.package) to `pkgs.mongodb-ce`.

View File

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