about summary refs log tree commit diff
path: root/pkgs/lib
diff options
context:
space:
mode:
authorMarc Weber <marco-oweber@gmx.de>2008-04-28 22:27:03 +0000
committerMarc Weber <marco-oweber@gmx.de>2008-04-28 22:27:03 +0000
commite17c96c8811a2a8a782fc1a428451c6f757af1cb (patch)
tree8a6a8699f5edd2d7d784ea1e667878fddc3cd889 /pkgs/lib
parent0875919fa1fe841b7469292aeb8da5b0c4d59a87 (diff)
downloadnixlib-e17c96c8811a2a8a782fc1a428451c6f757af1cb.tar
nixlib-e17c96c8811a2a8a782fc1a428451c6f757af1cb.tar.gz
nixlib-e17c96c8811a2a8a782fc1a428451c6f757af1cb.tar.bz2
nixlib-e17c96c8811a2a8a782fc1a428451c6f757af1cb.tar.lz
nixlib-e17c96c8811a2a8a782fc1a428451c6f757af1cb.tar.xz
nixlib-e17c96c8811a2a8a782fc1a428451c6f757af1cb.tar.zst
nixlib-e17c96c8811a2a8a782fc1a428451c6f757af1cb.zip
Support for profiling (all libraries) enabled by custom config
moved flapjax to ghcExecutables
added haskelldb mysql
added ghc darcs build (left in comments)

svn path=/nixpkgs/trunk/; revision=11742
Diffstat (limited to 'pkgs/lib')
-rw-r--r--pkgs/lib/default.nix19
1 files changed, 19 insertions, 0 deletions
diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix
index 8093c67a6923..2efd1adddb10 100644
--- a/pkgs/lib/default.nix
+++ b/pkgs/lib/default.nix
@@ -396,6 +396,25 @@ rec {
   # eg { a = 7; } {  a = [ 2 3 ]; } becomes { a = [ 7 2 3 ]; }
   mergeAttrsConcatenateValues = mergeAttrsWithFunc ( a : b : (toList a) ++ (toList b) );
 
+  # merges attributes using //, if a name exisits in both attributes
+  # an error will be triggered unless its listed in mergeLists
+  # so you can mergeAttrsNoOverride { buildInputs = [a]; } { buildInputs = [a]; } {} to get
+  # { buildInputs = [a b]; }
+  # merging buildPhase does'nt really make sense. The cases will be rare where appending /prefixing will fit your needs?
+  # in these cases the first buildPhase will override the second one
+  mergeAttrsNoOverride = { mergeLists ? ["buildInputs" "propagatedBuildInputs"],
+                           overrideSnd ? [ "buildPhase" ]
+                         } : attrs1 : attrs2 :
+    fold (n: set : 
+        setAttr set n ( if (__hasAttr n set) 
+            then # merge 
+              if elem n mergeLists # attribute contains list, merge them by concatenating
+                then (__getAttr n attrs2) ++ (__getAttr n attrs1)
+              else if elem n overrideSnd
+                then __getAttr n attrs1
+              else throw "error mergeAttrsNoOverride, attribute ${n} given in both attributes - no merge func defined"
+            else __getAttr n attrs2 # add attribute not existing in attr1
+           )) attrs1 (__attrNames attrs2);
   # returns atribute values as a list 
   flattenAttrs = set : map ( attr : builtins.getAttr attr set) (attrNames set);
   mapIf = cond : f :  fold ( x : l : if (cond x) then [(f x)] ++ l else l) [];