From fc3ac31540f57d933fcaca8b65c2a38491d8f369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Tue, 20 Mar 2012 18:49:44 +0000 Subject: [PATCH] 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. svn path=/nixpkgs/trunk/; revision=33304 --- pkgs/misc/my-env/default.nix | 13 ++++++------- pkgs/misc/my-env/loadenv.sh | 13 +++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 pkgs/misc/my-env/loadenv.sh diff --git a/pkgs/misc/my-env/default.nix b/pkgs/misc/my-env/default.nix index ab1eff9bf33b..660b757f3277 100644 --- a/pkgs/misc/my-env/default.nix +++ b/pkgs/misc/my-env/default.nix @@ -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 @@ mkDerivation { 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 ''; } diff --git a/pkgs/misc/my-env/loadenv.sh b/pkgs/misc/my-env/loadenv.sh new file mode 100644 index 000000000000..c116c14d8fe6 --- /dev/null +++ b/pkgs/misc/my-env/loadenv.sh @@ -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