summary refs log tree commit diff
path: root/pkgs/misc/my-env/default.nix
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/my-env/default.nix
parentb1da0a329cc2b65d4536b1b3ae7d0c04411bc3aa (diff)
downloadnixpkgs-3d90901798e1e17bde69014e7563d63da3d9b889.tar
nixpkgs-3d90901798e1e17bde69014e7563d63da3d9b889.tar.gz
nixpkgs-3d90901798e1e17bde69014e7563d63da3d9b889.tar.bz2
nixpkgs-3d90901798e1e17bde69014e7563d63da3d9b889.tar.lz
nixpkgs-3d90901798e1e17bde69014e7563d63da3d9b889.tar.xz
nixpkgs-3d90901798e1e17bde69014e7563d63da3d9b889.tar.zst
nixpkgs-3d90901798e1e17bde69014e7563d63da3d9b889.zip
update my_env. Hopefully does a better job now
svn path=/nixpkgs/trunk/; revision=13037
Diffstat (limited to 'pkgs/misc/my-env/default.nix')
-rw-r--r--pkgs/misc/my-env/default.nix79
1 files changed, 79 insertions, 0 deletions
diff --git a/pkgs/misc/my-env/default.nix b/pkgs/misc/my-env/default.nix
new file mode 100644
index 00000000000..2bf2d86c2c8
--- /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
+  '';
+}