You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.6 KiB
51 lines
1.6 KiB
9 years ago
|
# This expression returns a list of all fetchurl calls used by ‘expr’.
|
||
10 years ago
|
|
||
|
with import ../.. { };
|
||
|
with lib;
|
||
|
|
||
9 years ago
|
{ expr }:
|
||
9 years ago
|
|
||
10 years ago
|
let
|
||
|
|
||
9 years ago
|
root = expr;
|
||
10 years ago
|
|
||
|
uniqueUrls = map (x: x.file) (genericClosure {
|
||
|
startSet = map (file: { key = file.url; inherit file; }) urls;
|
||
|
operator = const [ ];
|
||
|
});
|
||
|
|
||
8 years ago
|
urls = map (drv: { url = head (drv.urls or [ drv.url ]); hash = drv.outputHash; type = drv.outputHashAlgo; name = drv.name; }) fetchurlDependencies;
|
||
10 years ago
|
|
||
9 years ago
|
fetchurlDependencies =
|
||
|
filter
|
||
8 years ago
|
(drv: drv.outputHash or "" != "" && drv.outputHashMode or "flat" == "flat"
|
||
8 years ago
|
&& drv.postFetch or "" == "" && (drv ? url || drv ? urls))
|
||
9 years ago
|
dependencies;
|
||
10 years ago
|
|
||
|
dependencies = map (x: x.value) (genericClosure {
|
||
|
startSet = map keyDrv (derivationsIn' root);
|
||
|
operator = { key, value }: map keyDrv (immediateDependenciesOf value);
|
||
|
});
|
||
|
|
||
|
derivationsIn' = x:
|
||
|
if !canEval x then []
|
||
|
else if isDerivation x then optional (canEval x.drvPath) x
|
||
|
else if isList x then concatLists (map derivationsIn' x)
|
||
5 years ago
|
else if isAttrs x then concatLists (mapAttrsToList (n: v: addErrorContext "while finding tarballs in '${n}':" (derivationsIn' v)) x)
|
||
10 years ago
|
else [ ];
|
||
|
|
||
|
keyDrv = drv: if canEval drv.drvPath then { key = drv.drvPath; value = drv; } else { };
|
||
|
|
||
|
immediateDependenciesOf = drv:
|
||
3 years ago
|
concatLists (mapAttrsToList (n: v: derivationsIn v) (removeAttrs drv (["meta" "passthru"] ++ optionals (drv?passthru) (attrNames drv.passthru))));
|
||
10 years ago
|
|
||
|
derivationsIn = x:
|
||
|
if !canEval x then []
|
||
|
else if isDerivation x then optional (canEval x.drvPath) x
|
||
|
else if isList x then concatLists (map derivationsIn x)
|
||
|
else [ ];
|
||
|
|
||
|
canEval = val: (builtins.tryEval val).success;
|
||
|
|
||
|
in uniqueUrls
|