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