diff options
author | pacien | 2022-08-22 18:31:14 +0200 |
---|---|---|
committer | pacien | 2022-08-22 18:31:14 +0200 |
commit | 96411aaa21543c81ce53fd9210e63c5e3d4ac519 (patch) | |
tree | 55d97ba83bc9ae6fad1ca4f9a8b17df7c114131f /lib | |
parent | 24a5cf35ea3b4c46a1a9dc6d39dd6a45d7b1c70c (diff) | |
download | flaky-utils-96411aaa21543c81ce53fd9210e63c5e3d4ac519.tar.gz |
bootstrap lib, add mkDevShell
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mk-dev-shell.nix | 30 |
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 | |||
6 | let | ||
7 | # TODO: escape values properly | ||
8 | exportEnvVar = k: v: ''export ${k}="${v}"; echo ${k}=\"${v}\"''; | ||
9 | exportedEnvVars = pkgs.lib.mapAttrsToList exportEnvVar envVars; | ||
10 | |||
11 | in 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 | } | ||