override-utils: minor refactor

This commit is contained in:
Andrew Kvalheim 2023-06-13 18:33:12 -07:00
parent f870fb9785
commit aa60d9a6aa

View file

@ -3,7 +3,7 @@
let
inherit (builtins) attrNames elemAt functionArgs isAttrs isPath length mapAttrs match pathExists removeAttrs toJSON tryEval;
inherit (stable) callPackage fetchFromGitHub;
inherit (stable.lib) attrByPath const findFirst getAttrFromPath hasAttrByPath info optionalAttrs optionalString showAttrPath throwIf versionAtLeast;
inherit (stable.lib) const findFirst getAttrFromPath hasAttrByPath info optionalAttrs optionalString showAttrPath throwIf versionAtLeast;
# Utilities
composeOverrides = f1: f2: a0: let o1 = f1 a0; o2 = f2 (a0 // o1); in o1 // o2;
@ -91,7 +91,7 @@ let
unnecessary = isStable repo && !doOverlay && !doOverride;
unnecessarySearch = search != null && repo.lib.trivial.version != search.lib.trivial.version;
in
if (attrByPath path { } stable) ? "overrideScope'" then
if hasAttrByPath (path ++ [ "overrideScope'" ]) stable then
(getAttrFromPath path stable).overrideScope' (_: _: mapAttrs (resolve path) spec)
else
throwIf unnecessarySearch "${name} no longer requires an extra search repository"