From e7412dde1f0a3d141839f05f5a06a12df84dc2c6 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 5 May 2021 18:53:28 +0200 Subject: [PATCH 1/2] Revert "lib/tests: Add type deprecation tests" This reverts commit 8b957e3b301d748e6fbbed806d82bd9d4b9d4ac4. --- lib/tests/modules.sh | 6 ---- lib/tests/modules/type-deprecation.nix | 39 -------------------------- 2 files changed, 45 deletions(-) delete mode 100644 lib/tests/modules/type-deprecation.nix diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 4259c538bb4..2e57c2f8e2a 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -272,12 +272,6 @@ checkConfigError 'A definition for option .fun.\[function body\]. is not of type checkConfigOutput "b a" config.result ./functionTo/list-order.nix checkConfigOutput "a c" config.result ./functionTo/merging-attrs.nix -## Type deprecation -checkConfigError 'The type `types.simple'\'' of option `simple'\'' defined in .* is deprecated. simple shall not be used' config.simple ./type-deprecation.nix -checkConfigError 'The type `types.infinite'\'' of option `infinite'\'' defined in .* is deprecated. infinite shall not be used' config.infinite ./type-deprecation.nix -checkConfigError 'The type `types.left'\'' of option `nested'\'' defined in .* is deprecated. left shall not be used' config.nested ./type-deprecation.nix -checkConfigError 'The type `types.right'\'' of option `nested'\'' defined in .* is deprecated. right shall not be used' config.nested ./type-deprecation.nix - cat < Date: Wed, 5 May 2021 18:53:34 +0200 Subject: [PATCH 2/2] Revert "lib/modules: Issue type deprecation warnings recursively" This reverts commit 4b54aedee5e05aaf2838f6d951508b83e33d2baa. --- lib/modules.nix | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/modules.nix b/lib/modules.nix index 04b65d791b5..d515ee24d16 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -515,20 +515,11 @@ rec { # yield a value computed from the definitions value = if opt ? apply then opt.apply res.mergedValue else res.mergedValue; - # Issue deprecation warnings recursively over all nested types of the - # given type. But don't recurse if a type with the same name was already - # visited before in order to prevent infinite recursion. So this only - # warns once per type name. - # Returns the new set of visited type names - recursiveWarn = visited: type: - let - maybeWarn = warnIf (type.deprecationMessage != null) - "The type `types.${type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${type.deprecationMessage}"; - in - if visited ? ${type.name} then visited - else lib.foldl' recursiveWarn (maybeWarn visited // { ${type.name} = null; }) (lib.attrValues type.nestedTypes); + warnDeprecation = + warnIf (opt.type.deprecationMessage != null) + "The type `types.${opt.type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${opt.type.deprecationMessage}"; - in builtins.seq (recursiveWarn {} opt.type) opt // + in warnDeprecation opt // { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value; inherit (res.defsFinal') highestPrio; definitions = map (def: def.value) res.defsFinal;