Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion nixos/modules/misc/documentation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 \
|| {
Expand Down
11 changes: 0 additions & 11 deletions nixos/modules/misc/version.nix
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ in

stateVersion = mkOption {
type = types.str;
default = cfg.release;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was going to suggest throwing a custom error in default, but that will obfuscate which system is missing this info. The module system's built-in message includes the entire attribute path.
(This is assuming NixOS gets hooked into a deployment tool's module system correctly; can't vouch for each of them, but NixOps has an open PR that will accomplish this.)

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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion nixos/modules/testing/test-instrumentation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
1 change: 1 addition & 0 deletions nixos/release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
Expand Down