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

View file

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

View file

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

View file

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