From 691842f527493a8a3440e5b29ba46a5e446a53b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Sat, 4 Jun 2022 23:37:06 +0200 Subject: [PATCH] nixos/version: Require a stateVersion 22.05 shows a warning for this, so we can safely remove it now. Users were warned. --- nixos/modules/misc/documentation.nix | 4 +++- nixos/modules/misc/version.nix | 11 ----------- nixos/modules/testing/test-instrumentation.nix | 1 - nixos/release.nix | 1 + 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/nixos/modules/misc/documentation.nix b/nixos/modules/misc/documentation.nix index 251a361a580c9..9ca9f5bfe137a 100644 --- a/nixos/modules/misc/documentation.nix +++ b/nixos/modules/misc/documentation.nix @@ -37,6 +37,8 @@ let scrubbedEval = evalModules { modules = [ { _module.check = false; + } { + config.system.stateVersion = config.system.stateVersion; } ] ++ docModules.eager; specialArgs = specialArgs // { pkgs = scrubDerivations "pkgs" pkgs; @@ -81,7 +83,7 @@ let --argstr pkgsLibPath "$pkgsLibPath" \ --argstr nixosPath "$nixosPath" \ --arg modules "[ $modules ]" \ - --argstr stateVersion "${options.system.stateVersion.default}" \ + --argstr stateVersion "${options.system.nixos.release.default}" \ --argstr release "${config.system.nixos.release}" \ $nixosPath/lib/eval-cacheable-options.nix > $out \ || { diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index b3cdaf5568d4f..662e86ff37a45 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -89,8 +89,6 @@ in stateVersion = mkOption { type = types.str; - default = cfg.release; - defaultText = literalExpression "config.${opt.release}"; description = lib.mdDoc '' Every once in a while, a new NixOS release may change configuration defaults in a way incompatible with stateful @@ -148,15 +146,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 diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index 4ab2578eb81e6..ea42c5d569d15 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -130,7 +130,6 @@ in # to reduce the closure size required for the tests. services.qemuGuest.package = pkgs.qemu_test.ga; - # Squelch warning about unset system.stateVersion system.stateVersion = lib.mkDefault lib.trivial.release; }; diff --git a/nixos/release.nix b/nixos/release.nix index f70b02c4292b4..207f40796b317 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -47,6 +47,7 @@ let versionModule = { system.nixos.versionSuffix = versionSuffix; system.nixos.revision = nixpkgs.rev or nixpkgs.shortRev; + system.stateVersion = version; }; makeModules = module: rest: [ configuration versionModule module rest ];