diff options
author | Robert Hensing <robert@roberthensing.nl> | 2022-12-22 19:51:11 +0100 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2022-12-28 14:35:14 +0100 |
commit | f03c7fb8d4e5fa75962f41b821b17e5ef8154c96 (patch) | |
tree | 83dcb419976e4814525e642114c07d77fabf616d /nixos/modules/misc/version.nix | |
parent | 9aa77715b71b7dd9cfbe14828eb82ae281af806c (diff) |
nixos/version: Only warn about unset stateVersion if used
If a configuration does not use services that depend on the stateVersion, it does not need to be set. This provides an incentive for services not to rely on stateVersion, and not to burden users with this.
Diffstat (limited to 'nixos/modules/misc/version.nix')
-rw-r--r-- | nixos/modules/misc/version.nix | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index b3cdaf5568d4f..1067b21a22b07 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -89,6 +89,12 @@ in stateVersion = mkOption { type = types.str; + # TODO Remove this and drop the default of the option so people are forced to set it. + # Doing this also means fixing the comment in nixos/modules/testing/test-instrumentation.nix + apply = v: + lib.warnIf (options.system.stateVersion.highestPrio == (lib.mkOptionDefault { }).priority) + "system.stateVersion is not set, defaulting to ${v}. Read why this matters on https://nixos.org/manual/nixos/stable/options.html#opt-system.stateVersion." + v; default = cfg.release; defaultText = literalExpression "config.${opt.release}"; description = lib.mdDoc '' @@ -149,14 +155,6 @@ in "os-release".text = attrsToText osReleaseContents; }; - # We have to use `warnings` because when warning in the default of the option - # the warning would also be shown when building the manual since the manual - # has to evaluate the default. - # - # TODO Remove this and drop the default of the option so people are forced to set it. - # Doing this also means fixing the comment in nixos/modules/testing/test-instrumentation.nix - warnings = lib.optional (options.system.stateVersion.highestPrio == (lib.mkOptionDefault { }).priority) - "system.stateVersion is not set, defaulting to ${config.system.stateVersion}. Read why this matters on https://nixos.org/manual/nixos/stable/options.html#opt-system.stateVersion."; }; # uses version info nixpkgs, which requires a full nixpkgs path |