aboutsummaryrefslogtreecommitdiff
path: root/pkgs/misc/my-env
diff options
context:
space:
mode:
authorMoritz Ulrich <moritz@tarn-vedra.de>2013-04-13 19:10:50 +0200
committerMoritz Ulrich <moritz@tarn-vedra.de>2013-04-13 19:10:50 +0200
commitd84bfa78e13a62928fa3ffd9d2f78a3d79a0708b (patch)
tree17a1350b047380aa9054b108f7102541e624d291 /pkgs/misc/my-env
parent50f3625f7024b6115c531ea8a9b850ceeb6e4220 (diff)
Add cleanupCmds option to pkgs.myEnvFun
This option allows the user to specify commands to run when the shell exits. This can be used to cleanup operations done in `extraCmds'. Signed-off-by: Moritz Ulrich <moritz@tarn-vedra.de>
Diffstat (limited to 'pkgs/misc/my-env')
-rw-r--r--pkgs/misc/my-env/default.nix9
-rw-r--r--pkgs/misc/my-env/loadenv.sh3
2 files changed, 10 insertions, 2 deletions
diff --git a/pkgs/misc/my-env/default.nix b/pkgs/misc/my-env/default.nix
index e68e4cab3492..e89a8ebb230d 100644
--- a/pkgs/misc/my-env/default.nix
+++ b/pkgs/misc/my-env/default.nix
@@ -59,7 +59,7 @@
{ mkDerivation, substituteAll, pkgs }:
{ stdenv ? pkgs.stdenv, name, buildInputs ? []
, propagatedBuildInputs ? [], gcc ? stdenv.gcc, cTags ? [], extraCmds ? ""
- , shell ? "${pkgs.bashInteractive}/bin/bash"}:
+ , cleanupCmds ? "", shell ? "${pkgs.bashInteractive}/bin/bash"}:
mkDerivation {
# The setup.sh script from stdenv will expect the native build inputs in
@@ -133,8 +133,15 @@ mkDerivation {
fi
rm -fr "\$tmp"
${extraCmds}
+
+ nix_cleanup() {
+ ${cleanupCmds}
+ }
+
export PATH
echo $name loaded
+
+ trap nix_cleanup EXIT
EOF
mkdir -p $out/bin
diff --git a/pkgs/misc/my-env/loadenv.sh b/pkgs/misc/my-env/loadenv.sh
index c116c14d8fe6..5d126f0c29bb 100644
--- a/pkgs/misc/my-env/loadenv.sh
+++ b/pkgs/misc/my-env/loadenv.sh
@@ -10,4 +10,5 @@ export buildInputs
export NIX_STRIP_DEBUG=0
export TZ="$OLDTZ"
-exec @shell@ --norc
+@shell@ --norc
+