diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2009-05-11 15:21:42 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2009-05-11 15:21:42 +0000 |
commit | abf71d53520a45654278a20910178f16ddbf823b (patch) | |
tree | 00397b55b06f3f0d6be6c7ce5f4edc7c3c9e4018 /pkgs/lib/strings-with-deps.nix | |
parent | 2f33cdec3896f45778064169639138bc4f75771a (diff) | |
download | nixpkgs-abf71d53520a45654278a20910178f16ddbf823b.tar nixpkgs-abf71d53520a45654278a20910178f16ddbf823b.tar.gz nixpkgs-abf71d53520a45654278a20910178f16ddbf823b.tar.bz2 nixpkgs-abf71d53520a45654278a20910178f16ddbf823b.tar.lz nixpkgs-abf71d53520a45654278a20910178f16ddbf823b.tar.xz nixpkgs-abf71d53520a45654278a20910178f16ddbf823b.tar.zst nixpkgs-abf71d53520a45654278a20910178f16ddbf823b.zip |
* textClosure: don't use uniqList, and don't rely on buggy behaviour
in the Nix expression evaluator (namely that comparison of attribute sets works properly). * Removed some redundant parentheses in builder-defs. svn path=/nixpkgs/trunk/; revision=15551
Diffstat (limited to 'pkgs/lib/strings-with-deps.nix')
-rw-r--r-- | pkgs/lib/strings-with-deps.nix | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/pkgs/lib/strings-with-deps.nix b/pkgs/lib/strings-with-deps.nix index 7664689647c..98ce4871da8 100644 --- a/pkgs/lib/strings-with-deps.nix +++ b/pkgs/lib/strings-with-deps.nix @@ -13,38 +13,35 @@ Usage: See trace/nixpkgs/trunk/pkgs/top-level/builder-defs.nix for some predefined build steps */ -args: -with args; -with lib; +{stdenv, lib}: -let - inherit (builtins) head tail isList isAttrs; -in +with lib; rec { - textClosureDupList = arg: - if isList arg then - textClosureDupList {text = ""; deps = arg;} - else - concatLists (map textClosureDupList arg.deps) ++ [arg]; - - textClosureDupListOverridable = predefined: arg: - if isList arg then - textClosureDupListOverridable predefined {text = ""; deps = arg;} - else if isAttrs arg then - concatLists (map (textClosureDupListOverridable predefined) arg.deps) ++ [arg] - else - textClosureDupListOverridable predefined (getAttr [arg] [] predefined); - - textClosureListOverridable = predefined: arg: - map (x: x.text) (uniqList {inputList = textClosureDupListOverridable predefined arg;}); - - textClosureOverridable = predefined: arg: concatStringsSep "\n" (textClosureListOverridable predefined arg); - - textClosureMapOveridable = f: predefined: arg: - concatStringsSep "\n" (map f (textClosureListOverridable predefined arg)); + /* !!! The interface of this function is kind of messed up, since + it's way too overloaded and almost but not quite computes a + topological sort of the depstrings. */ + + textClosureList = predefined: arg: + let + f = done: todo: + if todo == [] then {result = []; inherit done;} + else + let entry = head todo; in + if isAttrs entry then + let x = f done entry.deps; + y = f x.done (tail todo); + in { result = x.result ++ [entry.text] ++ y.result; + done = y.done; + } + else if hasAttr entry done then f done (tail todo) + else f (done // listToAttrs [{name = entry; value = 1;}]) ([(builtins.getAttr entry predefined)] ++ tail todo); + in (f {} arg).result; + + textClosureMap = f: predefined: names: + concatStringsSep "\n" (map f (textClosureList predefined names)); noDepEntry = text: {inherit text; deps = [];}; fullDepEntry = text: deps: {inherit text deps;}; |