mirror of
https://github.com/aviallon/nixos-lib.git
synced 2026-04-05 17:27:50 +00:00
[Lib/Attrsets]: attempt to fix merge with priority
This commit is contained in:
parent
1c7ee1e60a
commit
ecff52be0a
1 changed files with 11 additions and 3 deletions
|
|
@ -7,7 +7,15 @@ rec {
|
||||||
else
|
else
|
||||||
lib.modules.defaultOverridePriority
|
lib.modules.defaultOverridePriority
|
||||||
;
|
;
|
||||||
comparePriority = a: b: (getPriority a) - (getPriority b);
|
_getContent = x:
|
||||||
|
if isAttrs x && (attrByPath [ "_type" ] "" x) == "override" then
|
||||||
|
getAttr "content" x
|
||||||
|
else
|
||||||
|
x
|
||||||
|
;
|
||||||
|
|
||||||
|
# lower priority = higher precedence. If (comparePriority a b) is positive, b has higher precedence.
|
||||||
|
comparePriority = a: b: myLib.debug.traceValWithPrefix "comparePriority" (getPriority a) - (getPriority b);
|
||||||
mergeAttrsRecursiveWithPriority = a: b:
|
mergeAttrsRecursiveWithPriority = a: b:
|
||||||
let
|
let
|
||||||
_prio = comparePriority a b;
|
_prio = comparePriority a b;
|
||||||
|
|
@ -15,9 +23,9 @@ rec {
|
||||||
if _prio == 0 then
|
if _prio == 0 then
|
||||||
_mergeAttrsRecursive mergeAttrsRecursiveWithPriority a b
|
_mergeAttrsRecursive mergeAttrsRecursiveWithPriority a b
|
||||||
else if _prio > 0 then
|
else if _prio > 0 then
|
||||||
a
|
_getContent b
|
||||||
else
|
else
|
||||||
b
|
_getContent a
|
||||||
;
|
;
|
||||||
|
|
||||||
mergeAttrsRecursive = a: b: _mergeAttrsRecursive _mergeAttrsRecursive a b;
|
mergeAttrsRecursive = a: b: _mergeAttrsRecursive _mergeAttrsRecursive a b;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue