2019-11-11 18:38:42 +01:00
|
|
|
{ lib }:
|
|
|
|
|
|
|
|
with builtins;
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
rec {
|
|
|
|
ifelse = a: b: c: if a then b else c;
|
2020-03-11 01:53:04 +01:00
|
|
|
fileContentsOr = a: b: (ifelse
|
|
|
|
(pathIsRegularFile a)
|
|
|
|
a b);
|
2019-11-11 18:38:42 +01:00
|
|
|
cwd = toString ./.;
|
2020-05-10 17:16:08 +02:00
|
|
|
|
|
|
|
# lst (string PATH) (string FILETYPE) (bool RETURNFULLPATH)
|
2019-11-11 18:38:42 +01:00
|
|
|
lst = { p ? cwd, t ? "regular", b ? false }: (lists.forEach
|
|
|
|
(attrNames
|
|
|
|
(filterAttrs (n: v: v == t)
|
|
|
|
(readDir p)))
|
|
|
|
(v: ((optionalString b "${p}/") + v)));
|
|
|
|
lsf = p: (lst { p = p; });
|
|
|
|
lsd = p: (lst { p = p; t = "directory"; b = true; });
|
|
|
|
lsfRec = p: b: flatten ((map (np: lsfRec np b) (lsd p)) ++ (lst { p = p; b = b; }));
|
2020-03-27 13:25:54 +01:00
|
|
|
hasAttrs = aList: d: (map
|
|
|
|
(a:
|
|
|
|
(ifelse (isList a)
|
|
|
|
(hasAttrByPath a d)
|
|
|
|
(hasAttr a d)))
|
|
|
|
aList);
|
2020-05-10 17:16:08 +02:00
|
|
|
deps = p: ifelse (isAttrs p) (filter (p: isAttrs p)
|
|
|
|
(p.buildInputs ++ p.nativeBuildInputs ++ p.propagatedBuildInputs ++ p.propagatedNativeBuildInputs)
|
|
|
|
) [];
|
|
|
|
importFilter = l: p: filter (n: elem (nameFromURL (toString n) ".") l) p;
|
|
|
|
depsRec = ld: ifelse (ld == []) [] ((toList ld) ++ (depsRec (lists.unique (lists.flatten (map (d: deps d) (toList ld))))));
|
|
|
|
isBroken = p: ifelse ((elem true (hasAttrs [["meta" "broken"]] p)) && (p.meta.broken == true))
|
|
|
|
(warn "Package ${p.name} is marked as broken." true)
|
|
|
|
false;
|
|
|
|
depsBroken = p: lists.any (p: (isBroken p)) (deps p);
|
|
|
|
# Those two lines are quite magical 🧙
|
|
|
|
depsBrokenRec = p: (b: b == true) (ifelse (depsBroken p) true
|
|
|
|
(map (p: depsBrokenRec p) (deps p)));
|
|
|
|
pkgFilter = ld: (filter
|
2020-03-27 13:25:54 +01:00
|
|
|
(p: (
|
2020-05-10 17:16:08 +02:00
|
|
|
ifelse (isBroken p)
|
|
|
|
false
|
|
|
|
(ifelse (depsBrokenRec p)
|
|
|
|
(warn "Dependency of ${p.name} is marked as broken." false)
|
|
|
|
true)
|
|
|
|
))
|
|
|
|
ld);
|
2019-11-11 18:38:42 +01:00
|
|
|
}
|