aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/mk-dev-shell.nix30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/mk-dev-shell.nix b/lib/mk-dev-shell.nix
new file mode 100644
index 0000000..e0bb441
--- /dev/null
+++ b/lib/mk-dev-shell.nix
@@ -0,0 +1,30 @@
1{ pkgs
2, tools ? []
3, envVars ? {}
4}:
5
6let
7 # TODO: escape values properly
8 exportEnvVar = k: v: ''export ${k}="${v}"; echo ${k}=\"${v}\"'';
9 exportedEnvVars = pkgs.lib.mapAttrsToList exportEnvVar envVars;
10
11in pkgs.mkShell {
12 buildInputs = tools;
13
14 # TODO: handle case with no env variable set
15 # TODO: handle case with no package in tools
16 # TODO: allow custom shell
17 shellHook = ''
18 echo -e "\nDEVSHELL ENVIRONMENT VARIABLES:"
19 ${pkgs.lib.concatStringsSep "\n" exportedEnvVars}
20
21 echo -e "\nDEVSHELL COMMANDS:"
22 ls "${pkgs.symlinkJoin { name = "env"; paths = tools; }}/bin"
23
24 # Use the default user shell instead of Bash
25 $(${pkgs.finger_bsd}/bin/finger $USER \
26 | ${pkgs.gnugrep}/bin/grep -oP 'Shell: \K.*')
27
28 exit $?
29 '';
30}