Skip to content

Commit

Permalink
Merge pull request #207958 from hercules-ci/nixos-only-warn-stateVers…
Browse files Browse the repository at this point in the history
…ion-when-used-lite

nixos/version: Only warn about unset stateVersion if used (lite)
  • Loading branch information
roberth committed Dec 28, 2022
2 parents 9aa7771 + 91050a9 commit 8df1ea3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
14 changes: 6 additions & 8 deletions nixos/modules/misc/version.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''
Expand Down Expand Up @@ -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
Expand Down
20 changes: 19 additions & 1 deletion nixos/modules/profiles/macos-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ in

{ imports = [
../virtualisation/qemu-vm.nix

# Avoid a dependency on stateVersion
{
disabledModules = [
../virtualisation/nixos-containers.nix
../services/x11/desktop-managers/xterm.nix
];
config = {
};
options.boot.isContainer = lib.mkOption { default = false; internal = true; };
}
];

# The builder is not intended to be used interactively
Expand Down Expand Up @@ -97,7 +108,14 @@ in
# To prevent gratuitous rebuilds on each change to Nixpkgs
nixos.revision = null;

stateVersion = "22.05";
stateVersion = lib.mkDefault (throw ''
The macOS linux builder should not need a stateVersion to be set, but a module
has accessed stateVersion nonetheless.
Please inspect the trace of the following command to figure out which module
has a dependency on stateVersion.
nix-instantiate --attr darwin.builder --show-trace
'');
};

users.users."${user}"= {
Expand Down
6 changes: 6 additions & 0 deletions nixos/modules/services/matrix/synapse.nix
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,12 @@ in {
sqlite3 = null;
psycopg2 = "matrix-synapse";
}.${cfg.settings.database.name};
defaultText = lib.literalExpression ''
{
sqlite3 = null;
psycopg2 = "matrix-synapse";
}.''${cfg.settings.database.name};
'';
description = lib.mdDoc ''
Username to connect with psycopg2, set to null
when using sqlite3.
Expand Down

0 comments on commit 8df1ea3

Please sign in to comment.