summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Pierron <nicolas.b.pierron@gmail.com>2009-05-19 23:07:07 +0000
committerNicolas Pierron <nicolas.b.pierron@gmail.com>2009-05-19 23:07:07 +0000
commit1500252e6fa30fc8b615587bc13a8f470b071586 (patch)
tree387ccb00a7f0d0f3725ab32546a45fc62344de6a
parent47679b20afe2e8682a8d0d7420ccc1f03e429347 (diff)
downloadnixpkgs-1500252e6fa30fc8b615587bc13a8f470b071586.tar
nixpkgs-1500252e6fa30fc8b615587bc13a8f470b071586.tar.gz
nixpkgs-1500252e6fa30fc8b615587bc13a8f470b071586.tar.bz2
nixpkgs-1500252e6fa30fc8b615587bc13a8f470b071586.tar.lz
nixpkgs-1500252e6fa30fc8b615587bc13a8f470b071586.tar.xz
nixpkgs-1500252e6fa30fc8b615587bc13a8f470b071586.tar.zst
nixpkgs-1500252e6fa30fc8b615587bc13a8f470b071586.zip
* options.nix:
	Remove attribute set comparison.  Imported attribute sets
        are traverse assuming that no duplicate could exists.

svn path=/nixpkgs/trunk/; revision=15659
-rw-r--r--pkgs/lib/options.nix21
1 files changed, 18 insertions, 3 deletions
diff --git a/pkgs/lib/options.nix b/pkgs/lib/options.nix
index 713c8f0b372..bd42b1dcf34 100644
--- a/pkgs/lib/options.nix
+++ b/pkgs/lib/options.nix
@@ -146,6 +146,7 @@ rec {
   || builtins.isList x
   );
 
+
   # Evaluate a list of option sets that would be merged with the
   # function "merge" which expects two arguments.  The attribute named
   # "require" is used to imports option declarations and bindings.
@@ -192,13 +193,27 @@ rec {
             cfg3 = noImportConditions cfg2;
         in cfg3;
 
-      getRequire = x:
-        toList (getAttr ["require"] [] (preprocess x));
+      getRequire = x: toList (getAttr ["require"] [] (preprocess x));
+      getRecusiveRequire = x:
+        fold (cfg: l:
+          if isPath cfg then
+            [ cfg ] ++ l
+          else
+            [ cfg ] ++ (getRecusiveRequire cfg) ++ l
+        ) [] (getRequire x);
+
+      getRequireSets = x: filter (x: ! isPath x) (getRecusiveRequire x);
+      getRequirePaths = x: filter isPath (getRecusiveRequire x);
       rmRequire = x: removeAttrs (preprocess x) ["require"];
+
+      inlineRequiredSets = cfgs:
+        fold (cfg: l: [ cfg ] ++ (getRequireSets cfg) ++ l) [] cfgs;
     in
       merge "" (
         map rmRequire (
-          lib.uniqFlatten getRequire [] [] (toList opts)
+          inlineRequiredSets (
+            lib.uniqFlatten getRequirePaths [] [] (toList opts)
+          )
         )
       );