From 17fdb6f68af2e48cce69536e50b471391b22ad19 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 19 Apr 2026 13:00:03 +0100 Subject: [PATCH] types.attrListWith: init Trivial extraction from attrListOf. --- lib/types.nix | 6 ++++-- .../doc/manual/development/option-types.section.md | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/types.nix b/lib/types.nix index 34d5b600322e..836efdf41831 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -810,8 +810,10 @@ rec { substSubModules = m: nonEmptyListOf (elemType.substSubModules m); }; - attrListOf = - elemType: + attrListOf = elemType: attrListWith { inherit elemType; }; + + attrListWith = + { elemType }: mkOptionType rec { name = "attrListOf"; description = "attribute list of ${ diff --git a/nixos/doc/manual/development/option-types.section.md b/nixos/doc/manual/development/option-types.section.md index 24b966fbf3b3..ff35193a746c 100644 --- a/nixos/doc/manual/development/option-types.section.md +++ b/nixos/doc/manual/development/option-types.section.md @@ -512,6 +512,19 @@ Composed types are types that take a type as parameter. `listOf Multiple definitions of the same option are concatenated and then sorted by priority. Entries at the same priority level preserve their definition order. +`types.attrListWith` { *`elemType`* } + +: An ordered list of single-attribute attribute sets, where each value is of *`elemType`* type. + + **Parameters** + + `elemType` (Required) + : Specifies the type of each value in the attribute list. + + **Behavior** + + - `attrListWith { elemType = t; }` is equivalent to `attrListOf t` + `types.uniq` *`t`* : Ensures that type *`t`* cannot be merged. It is used to ensure option