From e2703d269756d27cff92ecb61c6da9d68ad8fdf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Mon, 24 May 2021 16:08:40 +0200 Subject: [PATCH 1/3] nixos/version: Warn about using the default of system.stateVersion --- nixos/modules/misc/version.nix | 9 +++++++++ nixos/modules/testing/test-instrumentation.nix | 3 +++ 2 files changed, 12 insertions(+) diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index 931201ade293..010acdb72f67 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -146,6 +146,15 @@ in "/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 diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index 81541477b9e0..4ab2578eb81e 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -129,6 +129,9 @@ in # 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; }; } From 4c5e7bde3e6056376e70448ee56a9baa7cc49dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Thu, 5 May 2022 00:56:54 +0200 Subject: [PATCH 2/3] nixos/matrix-synapse: Add a defaultText --- nixos/modules/services/matrix/matrix-synapse.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/services/matrix/matrix-synapse.nix b/nixos/modules/services/matrix/matrix-synapse.nix index a498aff7a55b..87a977f8e1ef 100644 --- a/nixos/modules/services/matrix/matrix-synapse.nix +++ b/nixos/modules/services/matrix/matrix-synapse.nix @@ -296,6 +296,7 @@ in { default = if lib.versionAtLeast config.system.stateVersion "22.05" then "${cfg.dataDir}/media_store" else "${cfg.dataDir}/media"; + defaultText = "${cfg.dataDir}/media_store for when system.stateVersion is at least 22.05, ${cfg.dataDir}/media when lower than 22.05"; description = '' Directory where uploaded images and attachments are stored. ''; From 0329256fd82af1a100e1b724efd9f735a5bec81d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Thu, 5 May 2022 12:51:39 +0200 Subject: [PATCH 3/3] nixos-functions: Set system.stateVersion --- pkgs/test/nixos-functions/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/test/nixos-functions/default.nix b/pkgs/test/nixos-functions/default.nix index f2914455246c..5e9857134de5 100644 --- a/pkgs/test/nixos-functions/default.nix +++ b/pkgs/test/nixos-functions/default.nix @@ -24,6 +24,7 @@ in lib.optionalAttrs stdenv.hostPlatform.isLinux ( system.nixos = dummyVersioning; boot.loader.grub.enable = false; fileSystems."/".device = "/dev/null"; + system.stateVersion = lib.trivial.release; }).toplevel; nixosTest-test = pkgs.nixosTest ({ lib, pkgs, figlet, ... }: { @@ -31,6 +32,7 @@ in lib.optionalAttrs stdenv.hostPlatform.isLinux ( nodes.machine = { pkgs, ... }: { system.nixos = dummyVersioning; environment.systemPackages = [ pkgs.hello figlet ]; + system.stateVersion = lib.trivial.release; }; testScript = '' machine.succeed("hello | figlet >/dev/console")