rename mergeStruct family of functions -> overrideStruct

This commit is contained in:
Emile Clark-Boman 2026-01-15 11:43:51 +10:00
parent b7af0be9b2
commit 81c83621d7

View file

@ -68,6 +68,7 @@ in rec {
}); });
# Alternative to mapAttrsRecursiveCond # Alternative to mapAttrsRecursiveCond
# Allows mapping directly from a child path
recmapCondFrom = path: cond: f: T: let recmapCondFrom = path: cond: f: T: let
delegate = path': recmapCondFrom path' cond f; delegate = path': recmapCondFrom path' cond f;
in in
@ -83,26 +84,28 @@ in rec {
# NOTE: refuses to go beyond Terminal types # NOTE: refuses to go beyond Terminal types
recmap = recmapCond (_: leaf: !(isTerminal leaf)); recmap = recmapCond (_: leaf: !(isTerminal leaf));
mergeStructsCond = cond: f: base: ext: overrideStructCond = cond: f: S: ext:
recmapCond recmapCond
cond cond
(path: leaf: (path: leaf:
attrValueAt path ext attrValueAt path ext
|> unwrapSome (_: f leaf)) |> unwrapSome (_: f leaf))
base; S;
# mergeStruct ensures no properties are evaluated (entirely lazy) # overrideStruct ensures no properties are evaluated (entirely lazy)
# TODO: should this be called "overlayStructs" or something? (its not exactly a merge...) # TODO: should this be called "overlayStructs" or something? (its not exactly a override...)
# NOTE: respects Terminal types # NOTE: respects Terminal types
mergeStructs = overrideStructs =
mergeStructsCond overrideStructCond
(_: leaf: !(isTerminal leaf)) (_: leaf: !(isTerminal leaf))
(leaf: (leaf:
if isTerminal leaf if isTerminal leaf
then unwrapTerminal leaf then unwrapTerminal leaf
else leaf); else leaf);
# # mergeTypedPartialStruct must evaluate properties (not lazy) # # overrideTypedPartialStruct must evaluate properties (not lazy)
# # for lazy evaluation use mergeStruct instead! # # for lazy evaluation use overrideStruct instead!
# mergeTypedPartialStruct = mergeStructs' cmpTypedPartialStruct; # overrideTypedPartialStruct = overrideStructs' cmpTypedPartialStruct;
overrideAttrs = A: B: A // B;
} }