summary refs log tree commit diff
path: root/pkgs/misc/misc.nix
diff options
context:
space:
mode:
authorMarc Weber <marco-oweber@gmx.de>2009-07-07 20:53:16 +0000
committerMarc Weber <marco-oweber@gmx.de>2009-07-07 20:53:16 +0000
commit5ef46894e0796f9eabdd96b07f7b591936170d55 (patch)
tree3315859cb47a46027628dd03d82f388f79f43b3e /pkgs/misc/misc.nix
parentdf4a8eafde6e65406ac258787f83c25bc6363c32 (diff)
downloadnixpkgs-5ef46894e0796f9eabdd96b07f7b591936170d55.tar
nixpkgs-5ef46894e0796f9eabdd96b07f7b591936170d55.tar.gz
nixpkgs-5ef46894e0796f9eabdd96b07f7b591936170d55.tar.bz2
nixpkgs-5ef46894e0796f9eabdd96b07f7b591936170d55.tar.lz
nixpkgs-5ef46894e0796f9eabdd96b07f7b591936170d55.tar.xz
nixpkgs-5ef46894e0796f9eabdd96b07f7b591936170d55.tar.zst
nixpkgs-5ef46894e0796f9eabdd96b07f7b591936170d55.zip
adding cdtEnv symlinking deps into one $out/cdt-env/{lib,include} directory
and collection which let's you install and update a set of derivations at once

svn path=/nixpkgs/trunk/; revision=16224
Diffstat (limited to 'pkgs/misc/misc.nix')
-rw-r--r--pkgs/misc/misc.nix107
1 files changed, 107 insertions, 0 deletions
diff --git a/pkgs/misc/misc.nix b/pkgs/misc/misc.nix
new file mode 100644
index 00000000000..667ca8aa572
--- /dev/null
+++ b/pkgs/misc/misc.nix
@@ -0,0 +1,107 @@
+{ pkgs, stdenv } :
+
+let inherit (pkgs) stdenv runCommand perl;
+
+in
+
+{
+
+  /* 
+
+    usage example creating a derivation installing ruby, sup and a lib:
+
+    packageOverrides = {
+      rubyCollection = collection {
+        name = "ruby";
+        list = let l = rubyLibs; in 
+          [ pkgs.ruby l.chronic l.sup ];
+      };
+    }
+
+  */
+  collection = {list, name} : runCommand "collection-${name}" {} ''
+    mkdir -p $out/nix-support
+    echo ${builtins.toString list} > $out/nix-support/propagated-user-env-packages
+  '';
+
+  /* creates a derivation symlinking references C/C++ libs into one include and lib directory called $out/cdt-envs/${name}
+     then you can
+     ln -s ~/.nix-profile/cdt-envs/name ./nix-deps
+     and add .nix-deps/{libs,includes} to IDE's such as Eclipse/ Netbeans etc.
+     To update replace library versions just replace the symlink
+  */
+  cdtEnv = { name, buildInputs }:
+    stdenv.mkDerivation {
+     name = "cdt-env-${name}";
+     inherit buildInputs;
+     phases = "installPhase";
+     installPhase = ''
+      set -x
+      # requires bash4
+      PATH=$PATH:${pkgs.pkgconfig}/bin
+
+      perlScript=$(dirname $(dirname ${builtins.getEnv "NIXPKGS_ALL"}))/build-support/buildenv/builder.pl
+      # now collect includes and lib paths
+
+      # probably the nix hooks work best, so reuse them by reading NIX_CFLAGS_COMPILE and NIX_LDFLAGS
+
+      PKG_CONFIG_KNOWN_PACKAGES=$(pkg-config --list-all | sed 's/ .*//')
+
+      declare -A INCLUDE_PATHS
+      declare -A LIB_PATHS
+      declare -A LIBS
+      declare -A CFLAGS_OTHER
+
+      PKG_CONFIG_LIBS="$(pkg-config --libs $PKG_CONFIG_KNOWN_PACKAGES)"
+      PKG_CONFIG_CFLAGS="$(pkg-config --cflags $PKG_CONFIG_KNOWN_PACKAGES)"
+
+      for i in $NIX_CFLAGS_COMPILE $PKG_CONFIG_CFLAGS; do
+        echo i is $i
+        case $i in
+          -I*) INCLUDE_PATHS["''${i/-I/}"]= ;;
+          *) CFLAGS_OTHER["''${i}"]= ;;
+        esac
+          echo list is now ''${!INCLUDE_PATHS[@]}
+      done
+
+      for i in $NIX_LDFLAGS $PKG_CONFIG_LIBS; do
+        case $i in
+          -L*)
+          LIB_PATHS["''${i/-L/}"]= ;;
+        esac
+      done
+
+      for i in $NIX_LDFLAGS $PKG_CONFIG_LIBS; do
+        echo chekcing $i
+        case $i in
+          -l*) LIBS["''${i}"]= ;;
+        esac;
+      done
+
+      # build output env
+
+      target="$out/cdt-envs/${name}"
+
+      link(){
+        echo "link !!!!"
+          echo $1
+          echo $2
+        (
+          export out="$1"
+          export paths="$2"
+
+          export ignoreCollisions=1
+          export manifest=
+          export pathsToLink=/
+          ${perl}/bin/perl $perlScript
+        )
+      }
+
+      ensureDir $target/{include,lib}
+      link $target/lib "$(echo "''${!LIB_PATHS[@]}")"
+      link $target/include "$(echo "''${!INCLUDE_PATHS[@]}")"
+      echo "''${!LIBS[@]}" > $target/libs
+      echo "''${!CFLAGS_OTHER[@]}" > $target/cflags-other
+    '';
+  };
+}