about summary refs log tree commit diff
path: root/pkgs/misc
diff options
context:
space:
mode:
authorMarc Weber <marco-oweber@gmx.de>2008-10-09 22:57:20 +0000
committerMarc Weber <marco-oweber@gmx.de>2008-10-09 22:57:20 +0000
commit3d90901798e1e17bde69014e7563d63da3d9b889 (patch)
treeb0fe233e6b3eb8fdf1b7f749c9025a9916da4baf /pkgs/misc
parentb1da0a329cc2b65d4536b1b3ae7d0c04411bc3aa (diff)
update my_env. Hopefully does a better job now
svn path=/nixpkgs/trunk/; revision=13037
Diffstat (limited to 'pkgs/misc')
-rw-r--r--pkgs/misc/my-env/default.nix79
-rw-r--r--pkgs/misc/my_env/default.nix58
2 files changed, 79 insertions, 58 deletions
diff --git a/pkgs/misc/my-env/default.nix b/pkgs/misc/my-env/default.nix
new file mode 100644
index 0000000000000..2bf2d86c2c81e
--- /dev/null
+++ b/pkgs/misc/my-env/default.nix
@@ -0,0 +1,79 @@
+# idea: provide nix environment for your developement actions
+# experimental
+
+/*
+  # example:
+  # add postgresql to environment and create ctags (tagfiles can be extracted from TAG_FILES)
+  # add this to your ~/.nixpkgs/config.nix
+
+  {
+    packageOverrides = pkgs : with pkgs; with sourceAndTags;
+    let simple = { name, buildInputs ? [], cTags ? [], extraCmds ? ""}:
+            pkgs.myEnvFun {
+              inherit name;
+            buildInputs = buildInputs 
+                  ++ map (x : sourceWithTagsDerivation ( (addCTaggingInfo x ).passthru.sourceWithTags ) ) cTags;
+            extraCmds = ''
+              ${extraCmds}
+              HOME=${builtins.getEnv "HOME"}
+              . ~/.bashrc
+            '';
+          };
+    in rec {
+      nixEnv = simple {
+       name = "nix";
+       buildInputs = [ libtool stdenv perl curl bzip2 openssl aterm242fixes db45 autoconf automake zlib ];
+       cTags = [ aterm242fixes];
+      };
+      [...]
+    };
+  }
+
+
+  Put this into your .bashrc
+    loadEnv(){ . "${HOME}/.nix-profile/dev-envs/${1}" }
+
+  then nix-env -iA ...nixEnv
+  and
+  $ loadEnv postgresql
+
+*/
+
+{ mkDerivation, substituteAll, pkgs } : { stdenv ? pkgs.stdenv, name, buildInputs ? [], cTags ? [], extraCmds ? ""} :
+mkDerivation {
+  buildInputs = [ ] ++ buildInputs ;
+  name = "env-${name}";
+  phases = "buildPhase";
+  setupNew = substituteAll {
+    src = ../../stdenv/generic/setup-new.sh;
+    preHook="";
+    postHook="";
+    initialPath= (import ../../stdenv/common-path.nix) { inherit pkgs; };
+    gcc = stdenv.gcc;
+  };
+  buildPhase = ''
+    set -x
+    mkdir -p "$out/dev-envs" "$out/nix-support"
+    s="$out/nix-support/setup-new-modified"
+    cp "$setupNew" "$s"
+    # shut some warning up.., do not use set -e
+    sed -e 's@set -e@@' \
+        -e 's@assertEnvExists\s\+NIX_STORE@:@' \
+        -e 's@trap.*@@' \
+        -i "$s"
+    cat >> "$out/dev-envs/''${name/env-/}" << EOF
+      buildInputs="$buildInputs"
+      # the setup-new script wants to write some data to a temp file.. so just let it do that and tidy up afterwards
+      tmp="\$("${pkgs.coreutils}/bin/mktemp" -d)"
+      NIX_BUILD_TOP="\$tmp"
+      phases=
+      # only do all the setup stuff in nix-support/*
+      set +e
+      source "$s"
+      rm -fr "\$tmp"
+      ${extraCmds}
+      export PATH
+      echo $name loaded
+    EOF
+  '';
+}
diff --git a/pkgs/misc/my_env/default.nix b/pkgs/misc/my_env/default.nix
deleted file mode 100644
index 9853041832d87..0000000000000
--- a/pkgs/misc/my_env/default.nix
+++ /dev/null
@@ -1,58 +0,0 @@
-# idea: provide nix environment for your developement actions
-# experimental
-
-/*
-  # example: 
-  # add postgresql to environment and create ctags (tagfiles can be extracted from TAG_FILES)
-  # add this to your ~/.nixpkgs/config.nix
-
- devEnvs = pkgs : with pkgs; with sourceAndTags;
-  let simple = { name, buildInputs ? [], cTags ? [] }:
-          pkgs.myEnvFun {
-            inherit name stdenv;
-          buildInputs = buildInputs 
-                ++ map (x : sourceWithTagsDerivation ( (addCTaggingInfo x ).passthru.sourceWithTags ) ) cTags;
-          extraCmds = ". ~/.bashrc; cd $PWD
-            # configure should find them
-            export LDFLAGS=$NIX_LDFLAGS
-            export CFLAGS=$NIX_CFLAGS_COMPILE
-            ";
-          preBuild = "export TAG_FILES";
-        };
-  in {
-    postgresql = simple {
-     name = "postgresql";
-     buildInputs = [postgresql];
-     cTags = [postgresql ];
-    };
-  };
-
-  Put this into your .bashrc
-    loadEnv(){ . "${HOME}/.nix-profile/dev-envs/${1}" }
-  then install and 
-    $ loadEnv postgresql
-
-*/
-
-args: args.stdenv.mkDerivation ( 
-  { extraCmds =""; } // {
-  phases = "buildPhase";
-  buildPhase = '' 
-    eval "$preBuild"
-    name=${args.name}
-    o=$out/dev-envs/$name
-    ensureDir `dirname $o`
-    echo "
-    OLDPATH=\$PATH " >> $o
-    export | grep -v HOME= | grep -v PATH= | grep -v PWD= | grep -v TEMP= | grep -v TMP= >> $o 
-    echo "
-    PATH=$PATH:$OLDPATH
-    for i in \$buildInputs; do
-      export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$i/lib
-    done
-    export PATH=\$PATH:\$OLDPATH
-    $extraCmds
-    echo env $name loaded
-    " >> $o
-  '';
-} // args // { name = "${args.name}-env"; } )