Skip to content

Commit

Permalink
lib/types: standardise attrsOf functor.wrapped warning and add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
infinisil committed Dec 2, 2024
1 parent 14f4431 commit dd5e03e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 4 additions & 0 deletions lib/tests/modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ checkConfigError 'The option `mergedLazyNonLazy'\'' in `.*'\'' is already declar
checkConfigOutput '^11$' config.lazyResult ./lazy-attrsWith.nix
checkConfigError 'infinite recursion encountered' config.nonLazyResult ./lazy-attrsWith.nix

# Test the attrsOf functor.wrapped warning
# shellcheck disable=2016
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `type.functor.wrapped` attribute of the option `mergedLazyLazy` is accessed, use `nestedTypes.elemType` instead.' options.mergedLazyLazy.type.functor.wrapped ./lazy-attrsWith.nix

# Even with multiple assignments, a type error should be thrown if any of them aren't valid
checkConfigError 'A definition for option .* is not of type .*' \
config.value ./declare-int-unsigned-value.nix ./define-value-list.nix ./define-value-int-positive.nix
Expand Down
8 changes: 2 additions & 6 deletions lib/types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -636,12 +636,8 @@ rec {
substSubModules = m: attrsWith { elemType = elemType.substSubModules m; inherit lazy; };
functor = defaultFunctor "attrsWith" // {
wrappedDeprecationMessage = { loc }: lib.warn ''
Using 'functor.wrapped' on option types will be deprecated.
Use 'nestedTypes.elemType' instead.
option: '${showOption loc}'
'' elemType;
The deprecated `type.functor.wrapped` attribute of the option `${showOption loc}` is accessed, use `nestedTypes.elemType` instead.
'' elemType;
payload = {
# Important!: Add new function attributes here in case of future changes
inherit elemType lazy;
Expand Down

0 comments on commit dd5e03e

Please sign in to comment.