From ac8670236f723ea4406f26ee75849e515f8a0d36 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Sun, 24 Nov 2024 17:47:41 +0100 Subject: [PATCH] lib.types.defaultTypeMerge: add 'loc' to default type merge --- lib/modules.nix | 3 ++- lib/types.nix | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/modules.nix b/lib/modules.nix index 855ffaf25ed81..08d15804daedb 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -11,6 +11,7 @@ let concatLists concatMap concatStringsSep + defaultTypeMerge elem filter foldl' @@ -749,7 +750,7 @@ let foldl' (res: opt: let t = res.type; t' = opt.options.type; - mergedType = t.typeMerge t'.functor; + mergedType = defaultTypeMerge loc t.functor t'.functor; typesMergeable = mergedType != null; typeSet = if (bothHave "type") && typesMergeable then { type = mergedType; } diff --git a/lib/types.nix b/lib/types.nix index 82d7425ca6439..5655fc598a814 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -82,7 +82,7 @@ rec { # Default type merging function # takes two type functors and return the merged type - defaultTypeMerge = f: f': + defaultTypeMerge = loc: f: f': let mergedWrapped = f.wrapped.typeMerge f'.wrapped.functor; mergedPayload = f.binOp f.payload f'.payload; @@ -103,6 +103,8 @@ rec { Use either `functor.payload` or `functor.wrapped` but not both. If your code worked before remove `functor.payload` from the type definition. + + Location: ${showOption loc} '' else # Has payload @@ -182,7 +184,7 @@ rec { , # Function that merge type declarations. # internal, takes a functor as argument and returns the merged type. # returning null means the type is not mergeable - typeMerge ? defaultTypeMerge functor + typeMerge ? defaultTypeMerge ["unknown location"] functor , # The type functor. # internal, representation of the type as an attribute set. # name: name of the type