diff options
-rw-r--r-- | lib/shell.nix | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/shell.nix b/lib/shell.nix index 63ef41a..a5b321d 100644 --- a/lib/shell.nix +++ b/lib/shell.nix | |||
@@ -4,10 +4,13 @@ flake: | |||
4 | 4 | ||
5 | with pkgs.lib; | 5 | with pkgs.lib; |
6 | 6 | ||
7 | let | 7 | rec { |
8 | mapAttrsToLines = mapping: attrs: | 8 | mapAttrsToLines = mapping: attrs: |
9 | concatStringsSep "\n" (mapAttrsToList mapping attrs); | 9 | concatStringsSep "\n" (mapAttrsToList mapping attrs); |
10 | 10 | ||
11 | ifSomeAttrs = attrs: f: pkgs.lib.optionalString (attrs != {}) (f attrs); | ||
12 | ifSomeList = list: f: pkgs.lib.optionalString (list != []) (f list); | ||
13 | |||
11 | fmt = rec { | 14 | fmt = rec { |
12 | codeBlock = code: text: ''"\e[${code}m"${escapeShellArg text}"\e[0m"''; | 15 | codeBlock = code: text: ''"\e[${code}m"${escapeShellArg text}"\e[0m"''; |
13 | keyword = codeBlock "1;36"; | 16 | keyword = codeBlock "1;36"; |
@@ -15,10 +18,6 @@ let | |||
15 | printSectionTitle = title: ''echo -e "\n"${section title}''; | 18 | printSectionTitle = title: ''echo -e "\n"${section title}''; |
16 | }; | 19 | }; |
17 | 20 | ||
18 | in rec { | ||
19 | ifSomeAttrs = attrs: f: pkgs.lib.optionalString (attrs != {}) (f attrs); | ||
20 | ifSomeList = list: f: pkgs.lib.optionalString (list != []) (f list); | ||
21 | |||
22 | exportEnvVar = k: v: '' | 21 | exportEnvVar = k: v: '' |
23 | export ${escapeShellArg k}="${v}" | 22 | export ${escapeShellArg k}="${v}" |
24 | ''; | 23 | ''; |