33 lines
833 B
Nix
33 lines
833 B
Nix
{ lib }:
|
|
|
|
with builtins;
|
|
with lib;
|
|
|
|
rec {
|
|
ifelse = a: b: c: if a then b else c;
|
|
fileContentsOr = a: b: (ifelse
|
|
(pathIsRegularFile a)
|
|
a b);
|
|
cwd = toString ./.;
|
|
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; }));
|
|
hasAttrs = aList: d: (map
|
|
(a:
|
|
(ifelse (isList a)
|
|
(hasAttrByPath a d)
|
|
(hasAttr a d)))
|
|
aList);
|
|
pkgFilter = l: (filter
|
|
(p: (
|
|
ifelse (elem true (hasAttrs [["meta" "broken"]] p))
|
|
(warn "Package ${p.name} is marked as broken." false)
|
|
true)
|
|
)
|
|
l);
|
|
}
|