about summary refs log tree commit diff
path: root/pkgs/lib
diff options
context:
space:
mode:
authorMarc Weber <marco-oweber@gmx.de>2008-02-12 16:24:02 +0000
committerMarc Weber <marco-oweber@gmx.de>2008-02-12 16:24:02 +0000
commit260c0c9c9678e164a42c5bfd6cb18cd143f32c0b (patch)
tree67f4d50103abd8206161f74e74823f4b0d62f45e /pkgs/lib
parent2fbd55bb6b5f9fb1d906b60889936e42b1b18ba0 (diff)
downloadnixlib-260c0c9c9678e164a42c5bfd6cb18cd143f32c0b.tar
nixlib-260c0c9c9678e164a42c5bfd6cb18cd143f32c0b.tar.gz
nixlib-260c0c9c9678e164a42c5bfd6cb18cd143f32c0b.tar.bz2
nixlib-260c0c9c9678e164a42c5bfd6cb18cd143f32c0b.tar.lz
nixlib-260c0c9c9678e164a42c5bfd6cb18cd143f32c0b.tar.xz
nixlib-260c0c9c9678e164a42c5bfd6cb18cd143f32c0b.tar.zst
nixlib-260c0c9c9678e164a42c5bfd6cb18cd143f32c0b.zip
new version - annotated derivation proposal - used to install addtiontal /src
and /tag/ source code which to build up develop environments more easily ( TODO
make this optional for ghcWrapper )

svn path=/nixpkgs/trunk/; revision=10648
Diffstat (limited to 'pkgs/lib')
-rw-r--r--pkgs/lib/annotatedDerivations.nix56
1 files changed, 56 insertions, 0 deletions
diff --git a/pkgs/lib/annotatedDerivations.nix b/pkgs/lib/annotatedDerivations.nix
new file mode 100644
index 000000000000..eca97747cd84
--- /dev/null
+++ b/pkgs/lib/annotatedDerivations.nix
@@ -0,0 +1,56 @@
+{ lib } : with lib; with builtins; rec {
+  /*
+  # traversal proposal (very unstable now )
+  # goal: create tags easily (and install source files along without recompiling)
+
+  rec {
+    # encouraged: using it you can filter based on names later on? Do we ned it?
+    name = 
+
+    # required: the annotated derivation (this attr is used to identify a
+    # annotated derivation)
+    aDeriv =
+
+    # required: extra list of annotated dependencies, so we can traverse the tree
+    aDeps = <annotated deps>
+
+    # your annotation derivations 
+  };
+  */
+
+  isAnnotated = a : (a ? aDeriv); # this function serves documentation purposes 
+
+  delAnnotation = a :
+    if ((__isAttrs a) && (isAnnotated a)) then  a.aDeriv
+    else a; # most probalby a derivation without annotations.
+
+  # returns buildInputs and propagatedBuildInputs from given set after removing annotations
+  delAnnotationsFromInputs = attrs :
+    subsetmap (map delAnnotation) attrs [ "buildInputs" "propagatedBuildInputs" ];
+
+  /* so an annotated drivation function might look like this
+  args: with args;
+    let aDeps = filterDeps args;
+        deps = delAnnotation aDeps;
+    in rec {
+      name = "my-package-0.2";
+      inherit aDeps;
+
+      aDeriv = stdenv.mkDerivation {
+        inherit name;
+        buildInputs = deps;
+      };
+    };
+
+  */
+
+  filterAnnotated = lib.filter isAnnotated;
+
+  # stops when depthCounter = 0 
+  traverseByDepthCounter = depthCounter : aAttrs :
+    if (depthCounter == 0) then []
+    else [ aAttrs ] ++ map (traverseByDepthCounter (__sub depthCounter 1) ) (filterAnnotated aAttrs.aDeps);
+
+  # get all deps recursively
+  uniqAnnotatedDeps = aAttrs : uniqList { inputList = traverseByDepthCounter 10 aAttrs; };
+}