aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorpacien2022-11-15 01:06:03 +0100
committerpacien2022-11-15 01:06:03 +0100
commit08e98e2e632a4b9db9568799f2b36aea345dc36d (patch)
tree97f2473b928d0961f422b3c73f610ee728c5ca61 /lib
parent2d2ab5d7e032300c0b391a36892b0b79b9b82f75 (diff)
downloadflaky-utils-08e98e2e632a4b9db9568799f2b36aea345dc36d.tar.gz
lib/shell: add optional print functions
Diffstat (limited to 'lib')
-rw-r--r--lib/mk-dev-shell.nix4
-rw-r--r--lib/mk-sandbox-system.nix4
-rw-r--r--lib/shell.nix3
3 files changed, 7 insertions, 4 deletions
diff --git a/lib/mk-dev-shell.nix b/lib/mk-dev-shell.nix
index 4f46d69..fe2ac02 100644
--- a/lib/mk-dev-shell.nix
+++ b/lib/mk-dev-shell.nix
@@ -13,8 +13,8 @@ in pkgs.mkShell {
13 shellHook = '' 13 shellHook = ''
14 ${shellLib.exportEnvVars envVars} 14 ${shellLib.exportEnvVars envVars}
15 15
16 ${pkgs.lib.optionalString (envVars != {}) (shellLib.printEnvVars envVars)} 16 ${shellLib.ifSomeAttrs envVars shellLib.printEnvVars}
17 ${pkgs.lib.optionalString (tools != []) (shellLib.printBins tools)} 17 ${shellLib.ifSomeList tools shellLib.printBins}
18 echo 18 echo
19 19
20 ${if (shell != null) then shell else shellLib.startUserShell} 20 ${if (shell != null) then shell else shellLib.startUserShell}
diff --git a/lib/mk-sandbox-system.nix b/lib/mk-sandbox-system.nix
index b678399..56ccad1 100644
--- a/lib/mk-sandbox-system.nix
+++ b/lib/mk-sandbox-system.nix
@@ -55,8 +55,8 @@ in rec {
55 # TODO: also print a summary of the host mount points 55 # TODO: also print a summary of the host mount points
56 # TODO: also print a summary of the forwarded ports 56 # TODO: also print a summary of the forwarded ports
57 interactiveShellInit = lib.mkBefore '' 57 interactiveShellInit = lib.mkBefore ''
58 ${lib.optionalString (envVars != {}) (shellLib.printEnvVars envVars)} 58 ${shellLib.ifSomeAttrs envVars shellLib.printEnvVars}
59 ${lib.optionalString (tools != []) (shellLib.printBins tools)} 59 ${shellLib.ifSomeList tools shellLib.printBins}
60 echo 60 echo
61 ''; 61 '';
62 }; 62 };
diff --git a/lib/shell.nix b/lib/shell.nix
index 3f6defc..d7d15fa 100644
--- a/lib/shell.nix
+++ b/lib/shell.nix
@@ -16,6 +16,9 @@ let
16 }; 16 };
17 17
18in rec { 18in rec {
19 ifSomeAttrs = attrs: f: pkgs.lib.optionalString (attrs != {}) (f attrs);
20 ifSomeList = list: f: pkgs.lib.optionalString (list != []) (f list);
21
19 exportEnvVar = k: v: '' 22 exportEnvVar = k: v: ''
20 export ${escapeShellArg k}="${v}" 23 export ${escapeShellArg k}="${v}"
21 ''; 24 '';