Author: viric
Date: Tue Mar 20 18:49:44 2012
New Revision: 33304
URL: https://nixos.org/websvn/nix/?rev=33304&sc=1

Log:
Updating the script of loading myEnv environments, for something close to what 
I was using.
It sets a fixed PS1, maybe breaking someone's taste, though. But I find it 
easier to use.

Added:
   nixpkgs/trunk/pkgs/misc/my-env/loadenv.sh
Modified:
   nixpkgs/trunk/pkgs/misc/my-env/default.nix

Modified: nixpkgs/trunk/pkgs/misc/my-env/default.nix
==============================================================================
--- nixpkgs/trunk/pkgs/misc/my-env/default.nix  Tue Mar 20 18:41:03 2012        
(r33303)
+++ nixpkgs/trunk/pkgs/misc/my-env/default.nix  Tue Mar 20 18:49:44 2012        
(r33304)
@@ -53,9 +53,10 @@
   #  $ load-nix-env
   # The result using that command should be:
   #  env-nix loaded
+  and show you a shell with a prefixed prompt.
 */
 
-{ mkDerivation, substituteAll, pkgs } : { stdenv ? pkgs.stdenv, name, 
buildInputs ? [], cTags ? [], extraCmds ? ""} :
+{ mkDerivation, substituteAll, pkgs } : { stdenv ? pkgs.stdenv, name, 
buildInputs ? [], cTags ? [], extraCmds ? "", shell ? 
"${pkgs.bashInteractive}/bin/bash"} :
 mkDerivation {
   # The setup.sh script from stdenv will expect the native build inputs in
   # the buildNativeInputs environment variable.
@@ -126,11 +127,9 @@
       echo $name loaded
     EOF
 
-    cat >> "$out/bin/load-''${name/env-/}-env" << EOF
-    #!/bin/sh
-
-    source "$out/dev-envs/''${name/env-/}"
-    EOF
-    chmod +x "$out/bin/load-''${name/env-/}-env" 
+    mkdir -p $out/bin
+    sed -e s,@shell@,${shell}, -e s,@myenvpath@,$out/dev-envs/${name}, \
+      -e s,@name@,${name}, ${./loadenv.sh} > $out/bin/load-${name}-env
+    chmod +x $out/bin/load-${name}-env
   '';
 }

Added: nixpkgs/trunk/pkgs/misc/my-env/loadenv.sh
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ nixpkgs/trunk/pkgs/misc/my-env/loadenv.sh   Tue Mar 20 18:49:44 2012        
(r33304)
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+OLDPATH="$PATH"
+OLDTZ="$TZ"
+source @myenvpath@
+
+PATH="$PATH:$OLDPATH"
+export PS1="\n@name@:[\u@\h:\w]\$ "
+export buildInputs
+export NIX_STRIP_DEBUG=0
+export TZ="$OLDTZ"
+
+exec @shell@ --norc
_______________________________________________
nix-commits mailing list
nix-comm...@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-commits

Reply via email to