override-utils: Report unnecessary local files
This commit is contained in:
parent
4cba8d86ce
commit
6b6fcc8b48
1 changed files with 8 additions and 5 deletions
|
@ -8,6 +8,7 @@ let
|
|||
# Utilities
|
||||
composeOverrides = f1: f2: a0: let o1 = f1 a0; o2 = f2 (a0 // o1); in o1 // o2;
|
||||
isEmpty = attrs: length (attrNames attrs) == 0;
|
||||
isLocal = r: isPath r;
|
||||
isStable = r: isAttrs r && ! r ? "_name";
|
||||
mkRepo = name: path: (import path { inherit (stable) config; overlays = [ ]; }) // { _name = name; };
|
||||
repoName = r: if isPath r then toString r else r._name or "stable";
|
||||
|
@ -62,13 +63,14 @@ let
|
|||
# Package selection
|
||||
path = scope ++ [ pname ];
|
||||
fullName = showAttrPath path;
|
||||
file = ./. + "/${fullName}.nix";
|
||||
suffices = r: r != null && hasAttrByPath path r
|
||||
&& (release == null || versionMeetsSpec r.lib.trivial.release release)
|
||||
&& (version == null || versionMeetsSpec (getAttrFromPath path r).version version)
|
||||
&& (condition == null || condition (getAttrFromPath path r));
|
||||
extra = if search == null then [ ] else imap1 (i: s: { _extra = i; _name = "search"; } // s) (toList search);
|
||||
repos = [ stable unstable ] ++ extra;
|
||||
repo = findFirst suffices (./. + "/${fullName}.nix") repos;
|
||||
repo = findFirst suffices file repos;
|
||||
package =
|
||||
if isPath repo then
|
||||
throwIf (! pathExists repo) "${query} not found in ${concatMapStringsSep ", " repoName (repos ++ [repo])}"
|
||||
|
@ -120,6 +122,7 @@ let
|
|||
(optionalString (condition != null) " meeting condition") +
|
||||
(optionalString (! isStable repo) " via ${repoName repo}");
|
||||
unnecessary = isStable repo && !doOverlay && !doOverride && !doWrapper;
|
||||
unnecessaryFile = ! isLocal repo && pathExists file;
|
||||
unnecessarySearches = concatMapStringsSep ", " repoName (filter (r: r._extra > repo._extra or 0) extra);
|
||||
in
|
||||
if hasAttrByPath (path ++ [ "overrideScope'" ]) stable then
|
||||
|
@ -127,10 +130,10 @@ let
|
|||
else if recurseForDerivations || (attrByPath (path ++ [ "recurseForDerivations" ]) false repo) then
|
||||
(attrByPath path { } repo) // { recurseForDerivations = false; } // (mapAttrs (resolve path) spec)
|
||||
else
|
||||
info summary (
|
||||
throwIf (unnecessarySearches != "") "${query} no longer requires searching ${unnecessarySearches}"
|
||||
(throwIf unnecessary "${query} no longer requires an override")
|
||||
package_with_overlay_with_override_with_wrapper)
|
||||
(throwIf unnecessaryFile "${query} no longer requires ${file}")
|
||||
(throwIf (unnecessarySearches != "") "${query} no longer requires searching ${unnecessarySearches}")
|
||||
(throwIf unnecessary "${query} no longer requires an override")
|
||||
(info summary package_with_overlay_with_override_with_wrapper)
|
||||
;
|
||||
in
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue