From ae142b573887422d6bf0a560528bb9e4f78673b7 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Sun, 24 May 2026 15:23:24 +0200 Subject: [PATCH] types.attrListWith: review fixes - Improve extractItem error messages: distinguish non-attrset elements from multi-key attrsets, and include the faulty definition via showDefs. - Use isType instead of raw _type access for order detection. - Disable type merging (typeMerge = t: null) instead of providing a functor-based merge. Add test confirming duplicate declarations fail. --- lib/tests/modules.sh | 7 ++++-- .../modules/declare-attrList-type-merge.nix | 12 +++++++++ lib/types.nix | 25 +++++++++++-------- 3 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 lib/tests/modules/declare-attrList-type-merge.nix diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index c7b661e2e2fe..4eb86ddd4962 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -902,13 +902,16 @@ checkConfigError 'Did you mean .services\.nginx\.virtualHosts\."example\.com"\.s # types.attrListOf checkConfigOutput '"ok"' config.assertions ./declare-attrList.nix checkConfigError 'A definition for option .attrListInt.badValue.a. is not of type .signed integer.. Definition values:' config.attrListIntStrict.badValue ./declare-attrList.nix -checkConfigError 'A definition for option .attrList.badListElem. is not of type .attribute list of string.. Each list element must be a single-key attribute set.' config.attrListStrict.badListElem ./declare-attrList.nix +checkConfigError 'A definition for option .attrList.badListElem. is not of type .attribute list of string.. Each list element must be a single-key attribute set, but got 2 keys' config.attrListStrict.badListElem ./declare-attrList.nix checkConfigError 'A definition for option .attrList.badString. is not of type .attribute list of string.. TypeError: Definition values:' config.attrListStrict.badString ./declare-attrList.nix -checkConfigError 'A definition for option .attrList.badListString. is not of type .attribute list of string.. Each list element must be a single-key attribute set.' config.attrListStrict.badListString ./declare-attrList.nix +checkConfigError 'A definition for option .attrList.badListString. is not of type .attribute list of string.. Each list element must be an attribute set, but got string' config.attrListStrict.badListString ./declare-attrList.nix # attrListWith valueMeta.definitions: file propagation checkConfigError 'the-defs-file\.nix' config.argv ./attrList-valueMeta-definitions-file-diagnostic-forwarding.nix +# attrListOf does not support type merging +checkConfigError 'The option .merged. in .*/declare-attrList-type-merge.nix. is already declared in .*/declare-attrList-type-merge.nix' config.merged ./declare-attrList-type-merge.nix + cat <