nixos/version: Warn about using the default of system.stateVersion

Changed files
+12
nixos
modules
+9
nixos/modules/misc/version.nix
···
"/etc/os-release".source = initrdRelease;
"/etc/initrd-release".source = initrdRelease;
};
};
# uses version info nixpkgs, which requires a full nixpkgs path
···
"/etc/os-release".source = initrdRelease;
"/etc/initrd-release".source = initrdRelease;
};
+
+
# 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
+3
nixos/modules/testing/test-instrumentation.nix
···
# Make sure we use the Guest Agent from the QEMU package for testing
# to reduce the closure size required for the tests.
services.qemuGuest.package = pkgs.qemu_test.ga;
};
}
···
# Make sure we use the Guest Agent from the QEMU package for testing
# 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;
};
}