refactor(readTree): Move 'drvTargets' into readTree
This function is also generally useful for readTree consumers that have the concept of subtargets. Change-Id: Ic7fc03380dec6953fb288763a28e50ab3624d233
This commit is contained in:
parent
5cad3f7b81
commit
4f1249e46f
19 changed files with 34 additions and 40 deletions
|
|
@ -157,6 +157,10 @@ let
|
|||
})
|
||||
(node.meta.targets or []))
|
||||
else [];
|
||||
|
||||
# Determine whether a given value is a derivation.
|
||||
# Copied from nixpkgs/lib for cases where lib is not available yet.
|
||||
isDerivation = x: isAttrs x && x ? type && x.type == "derivation";
|
||||
in {
|
||||
inherit gather;
|
||||
|
||||
|
|
@ -210,4 +214,17 @@ in {
|
|||
#
|
||||
# It is often required to create the args attribute set.
|
||||
fix = f: let x = f x; in x;
|
||||
|
||||
# Takes an attribute set and adds a meta.targets attribute to it
|
||||
# which contains all direct children of the attribute set which are
|
||||
# derivations.
|
||||
#
|
||||
# Type: attrs -> attrs
|
||||
drvTargets = attrs: attrs // {
|
||||
meta = {
|
||||
targets = builtins.filter
|
||||
(x: isDerivation attrs."${x}")
|
||||
(builtins.attrNames attrs);
|
||||
} // (attrs.meta or {});
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,6 @@
|
|||
{ depot, lib, ... }:
|
||||
|
||||
let
|
||||
|
||||
/* Takes an attribute set and adds a meta.targets
|
||||
attribute to it which contains all direct children
|
||||
of the attribute set which are derivations.
|
||||
|
||||
Type: attrs -> attrs
|
||||
*/
|
||||
drvTargets = attrs:
|
||||
attrs // {
|
||||
meta = {
|
||||
targets = builtins.filter
|
||||
(x: lib.isDerivation attrs."${x}")
|
||||
(builtins.attrNames attrs);
|
||||
} // (attrs.meta or {});
|
||||
};
|
||||
|
||||
/* Get the basename of a store path without
|
||||
the leading hash.
|
||||
|
||||
|
|
@ -186,7 +170,6 @@ let
|
|||
|
||||
in {
|
||||
inherit
|
||||
drvTargets
|
||||
storePathName
|
||||
pathType
|
||||
isDirectory
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ let
|
|||
'');
|
||||
|
||||
|
||||
in depot.nix.utils.drvTargets {
|
||||
in depot.nix.readTree.drvTargets {
|
||||
inherit
|
||||
rustTransitiveLib
|
||||
rustWithLib
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue