pipeList -> listify

This commit is contained in:
Daylin Morgan 2024-08-12 11:39:14 -05:00
parent 79c7654486
commit 2635aa5b57
Signed by: daylin
GPG key ID: 950D13E9719334AD
4 changed files with 36 additions and 15 deletions

View file

@ -1,14 +1,14 @@
{
enabled,
enableAttrs,
pipeList,
listify,
...
}:
{
oizys = {
rune.motd = enabled;
languages = "nim|node|python|nushell" |> pipeList;
} // ("docker|backups|nix-ld" |> pipeList |> enableAttrs);
languages = "nim|node|python|nushell" |> listify;
} // ("docker|backups|nix-ld" |> listify |> enableAttrs);
services.restic.backups.gdrive = {
# directories created by gitea and soft-serve aren't world readable

View file

@ -3,15 +3,24 @@
config,
enabled,
enableAttrs,
pipeList,
listify,
...
}:
{
oizys = {
oizys =
{
nix-ld = enabled // {
overkill = enabled;
};
languages = "misc|nim|node|nushell|python|roc|tex|zig" |> pipeList;
} // ("vpn|desktop|hyprland|chrome|docker|vbox|backups|hp-scanner|llm" |> pipeList |> enableAttrs);
languages = "misc|nim|node|nushell|python|roc|tex|zig" |> listify;
}
// (
''
vpn|desktop|hyprland|chrome
docker|vbox|backups|hp-scanner|llm
''
|> listify
|> enableAttrs
);
}

View file

@ -14,6 +14,7 @@ let
mkOption
types
splitString
trim
;
inherit (final.filesystem) listFilesRecursive;
in
@ -26,8 +27,19 @@ let
enable = false;
};
# "opt1|opt2" |> pipeList -> ["opt1" "opt2"]
pipeList = s: s |> replaceStrings [ "\n" ] [ "|" ] |> splitString "|" |> filter (s': s' != "");
# split a string on newlines and pipes to generate list
# "opt1|opt2" |> listify -> ["opt1" "opt2"]
# ''
# opt1
# opt2|opt3
# '' |> listify ["opt1" "opt2" "opt3"]
listify =
s:
s
|> replaceStrings [ "\n" ] [ "|" ]
|> splitString "|"
|> filter (s': s' != "")
|> map (s': trim s');
# ["a" "b"] -> {a.enable = true; b.enable = true;}
enableAttrs =
@ -112,6 +124,6 @@ in
pkgFromSystem
overlayFrom
flakeFromSystem
pipeList
listify
;
}

View file

@ -14,7 +14,7 @@ let
enableAttrs
isNixFile
flakeFromSystem
pipeList
listify
;
inherit (lib.filesystem) listFilesRecursive;
@ -59,7 +59,7 @@ let
inherit
mkDefaultOizysModule
mkOizysModule
pipeList
listify
enableAttrs
hostName
flake