From ad10d4fdef46a00bbe2d95aadc96b9e062fe0539 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sat, 29 Oct 2022 07:58:02 -0400 Subject: [PATCH 1/2] lib.modules.doRename: Don't define warning, even as undefined, if not warning. This fixes mkAliasOptionModule in systems with no warning option. --- lib/modules.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/modules.nix b/lib/modules.nix index a7fbec93a2f5..204a2cc1ac12 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -1135,10 +1135,10 @@ rec { type = toType; }); config = mkMerge [ - { + (optionalAttrs (options ? warnings) { warnings = optional (warn && fromOpt.isDefined) "The option `${showOption from}' defined in ${showFiles fromOpt.files} has been renamed to `${showOption to}'."; - } + }) (if withPriority then mkAliasAndWrapDefsWithPriority (setAttrByPath to) fromOpt else mkAliasAndWrapDefinitions (setAttrByPath to) fromOpt) From 1b6e5ac9520ebcfc283cd18c10856cdcd94c91eb Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 3 Nov 2022 13:11:04 +0100 Subject: [PATCH 2/2] lib/tests/modules: Test doRename --- lib/tests/modules.sh | 7 +++++++ lib/tests/modules/doRename-basic.nix | 11 +++++++++++ lib/tests/modules/doRename-warnings.nix | 14 ++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 lib/tests/modules/doRename-basic.nix create mode 100644 lib/tests/modules/doRename-warnings.nix diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index c9ea674ee104..6d2eb24db55c 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -348,6 +348,13 @@ checkConfigOutput 'ok' config.freeformItems.foo.bar ./adhoc-freeformType-survive # because of an `extendModules` bug, issue 168767. checkConfigOutput '^1$' config.sub.specialisation.value ./extendModules-168767-imports.nix +# doRename works when `warnings` does not exist. +checkConfigOutput '^1234$' config.c.d.e ./doRename-basic.nix +# doRename adds a warning. +checkConfigOutput '^"The option `a\.b. defined in `.*/doRename-warnings\.nix. has been renamed to `c\.d\.e.\."$' \ + config.result \ + ./doRename-warnings.nix + cat <