-
Notifications
You must be signed in to change notification settings - Fork 10
/
deps.nix
33 lines (33 loc) · 1.36 KB
/
deps.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{ lib, coqPackages }:
with builtins; with lib;
let
initialCoqPkgs = filterAttrs (_: isDerivation) coqPackages;
pkgsRevmap =
mapAttrs' (n: v: { name = "${v.name}"; value = n; }) initialCoqPkgs;
coqPkgs = filterAttrs (n: v: elem n (attrValues pkgsRevmap)) initialCoqPkgs;
pkgsDeps =
let
findInput = x: let n = if isNull x then null else
pkgsRevmap."${x.name}" or null; in
if isNull n then [ ] else [ n ];
deepFlatten = l: if !isList l then l else if l == [] then [] else
(if isList (head l) then deepFlatten (head l) else [ (head l) ])
++ deepFlatten (tail l);
in
flip mapAttrs coqPkgs (n: v: flatten
(map findInput (deepFlatten [v.buildInputs v.propagatedBuildInputs]))
);
pkgsSorted = (toposort (x: y: elem x pkgsDeps.${y}) (attrNames coqPkgs)).result;
pkgsRevDepsSetNoAlias = foldl (done: p: foldl (done: d:
done // { ${p} = done.${p} or {}; }
// { ${d} = (done.${d} or {}) // { ${p} = true;} // (done.${p} or {});}
) done pkgsDeps.${p}
) {} (reverseList pkgsSorted);
pkgsRevDepsSet = mapAttrs
(_: p: let pname = pkgsRevmap.${p.name} or p.name; in
pkgsRevDepsSetNoAlias.${pname} or {}) initialCoqPkgs;
pkgsRevDeps = mapAttrs (n: v: attrNames v) pkgsRevDepsSet;
in
{
inherit pkgsDeps pkgsSorted pkgsRevDeps pkgsRevDepsSet;
}