Add helper functions. -> should lead to code deduplication in the future.
This commit is contained in:
parent
c33b4517a7
commit
0d9fa5b37e
1 changed files with 17 additions and 0 deletions
17
fn.nix
Normal file
17
fn.nix
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{ lib }:
|
||||||
|
|
||||||
|
with builtins;
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
rec {
|
||||||
|
ifelse = a: b: c: if a then b else c;
|
||||||
|
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; }));
|
||||||
|
}
|
Loading…
Reference in a new issue