summary refs log tree commit diff
path: root/pkgs/lib/composable-derivation.nix
diff options
context:
space:
mode:
authorMarc Weber <marco-oweber@gmx.de>2008-12-20 01:20:35 +0000
committerMarc Weber <marco-oweber@gmx.de>2008-12-20 01:20:35 +0000
commite996113be7f41f067aaefac881c540b5ceb8d2d4 (patch)
tree177f16552ca2d05020c3d45a0b45502556a09502 /pkgs/lib/composable-derivation.nix
parent5ab6464edb9bbc2a9aa15122ffc02b57ad236bb7 (diff)
downloadnixpkgs-e996113be7f41f067aaefac881c540b5ceb8d2d4.tar
nixpkgs-e996113be7f41f067aaefac881c540b5ceb8d2d4.tar.gz
nixpkgs-e996113be7f41f067aaefac881c540b5ceb8d2d4.tar.bz2
nixpkgs-e996113be7f41f067aaefac881c540b5ceb8d2d4.tar.lz
nixpkgs-e996113be7f41f067aaefac881c540b5ceb8d2d4.tar.xz
nixpkgs-e996113be7f41f067aaefac881c540b5ceb8d2d4.tar.zst
nixpkgs-e996113be7f41f067aaefac881c540b5ceb8d2d4.zip
removed mkDerivationByConfiguration, using composableDerivation instead
qgis, vim_configurable both work now

svn path=/nixpkgs/trunk/; revision=13661
Diffstat (limited to 'pkgs/lib/composable-derivation.nix')
-rw-r--r--pkgs/lib/composable-derivation.nix46
1 files changed, 46 insertions, 0 deletions
diff --git a/pkgs/lib/composable-derivation.nix b/pkgs/lib/composable-derivation.nix
new file mode 100644
index 00000000000..790a0bcc9db
--- /dev/null
+++ b/pkgs/lib/composable-derivation.nix
@@ -0,0 +1,46 @@
+{lib, pkgs} :
+let inherit (lib) nv nvs; in
+{
+  # see new python derivations for example..
+  # You should be able to override anything you like easily
+  # grep the mailinglist by title "python proposal" (dec 08)
+  # -> http://mail.cs.uu.nl/pipermail/nix-dev/2008-December/001571.html
+  # to see why this got complicated when using all its features
+  composableDerivation = {
+          # modify args before applying stdenv.mkDerivation, this should remove at least attrs removeAttrsBy
+        f ? lib.prepareDerivationArgs,
+        stdenv ? pkgs.stdenv,
+          # initial set of arguments to be passed to stdenv.mkDerivation passing prepareDerivationArgs by default
+        initial ? {},
+          # example func :  (x: x // { x.buildInputs ++ ["foo"] }), but see mergeAttrByFunc which does this for you
+        merge ? (lib.mergeOrApply lib.mergeAttrByFunc)
+      }: lib.applyAndFun
+            (args: stdenv.mkDerivation (f args))
+            merge
+            (merge { inherit (lib) mergeAttrBy; } initial);
+
+  # some utility functions
+  # use this function to generate flag attrs for prepareDerivationArgs
+  # E nable  D isable F eature
+  edf = {name, feat ? name, enable ? {}, disable ? {} , value ? ""}:
+    nvs name {
+    set = {
+      configureFlags = ["--enable-${feat}${if value == "" then "" else "="}${value}"];
+    } // enable;
+    unset = {
+      configureFlags = ["--disable-${feat}"];
+    } // disable;
+  };
+
+  # same for --with and --without-
+  # W ith or W ithout F eature
+  wwf = {name, feat ? name, enable ? {}, disable ? {}, value ? ""}:
+    nvs name {
+    set = {
+      configureFlags = ["--with-${feat}${if value == "" then "" else "="}${value}"];
+    } // enable;
+    unset = {
+      configureFlags = ["--without-${feat}"];
+    } // disable;
+  };
+}