From c2b18e3f862bdb61486d8027de4d8dd5b6114012 Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 15 Nov 2022 01:14:22 +0100 Subject: lib/shell: expose util functions --- lib/shell.nix | 9 ++++----- 1 file 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: with pkgs.lib; -let +rec { mapAttrsToLines = mapping: attrs: concatStringsSep "\n" (mapAttrsToList mapping attrs); + ifSomeAttrs = attrs: f: pkgs.lib.optionalString (attrs != {}) (f attrs); + ifSomeList = list: f: pkgs.lib.optionalString (list != []) (f list); + fmt = rec { codeBlock = code: text: ''"\e[${code}m"${escapeShellArg text}"\e[0m"''; keyword = codeBlock "1;36"; @@ -15,10 +18,6 @@ let printSectionTitle = title: ''echo -e "\n"${section title}''; }; -in rec { - ifSomeAttrs = attrs: f: pkgs.lib.optionalString (attrs != {}) (f attrs); - ifSomeList = list: f: pkgs.lib.optionalString (list != []) (f list); - exportEnvVar = k: v: '' export ${escapeShellArg k}="${v}" ''; -- cgit v1.2.3