From 6d4fa01f1e681be36f3122b2359b953a8e41ccc7 Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Sun, 26 Aug 2007 21:59:31 +0000 Subject: [PATCH] Added strings-with-deps, a set of functions that are intended to build a minimal text which includes given strings and satisfies 'dependencies' of type A requires B to go before it. Just like global variable intialization must occur before using them. Supposed to be used for constructing builder.sh . svn path=/nixpkgs/trunk/; revision=9196 --- pkgs/lib/strings-with-deps.nix | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 pkgs/lib/strings-with-deps.nix diff --git a/pkgs/lib/strings-with-deps.nix b/pkgs/lib/strings-with-deps.nix new file mode 100644 index 000000000000..5f6cafaa67ad --- /dev/null +++ b/pkgs/lib/strings-with-deps.nix @@ -0,0 +1,48 @@ +args: + with args; + with lib; + let + inherit (builtins) + head tail isList; +rec { + +/* + let shelllib = rec { + a= { + text = "aaaa"; + deps = [b c]; + }; + b = { + text = "b"; + }; + c = { + text = "c"; + deps = []; + }; + }; + in + + [textClosure [shelllib.a] + textclosure shelllib.a]; + + +*/ + + textClosureDupList = arg: + ( + if isList arg then + textClosureDupList {text = ""; deps = arg;} + else + (if (arg ? deps) then + map textClosureDupList arg.deps + else []) + ++ [arg] + ); + + textClosureList = arg: uniqList (textClosureDupList arg); + textClosure = arg: concatStringsSep " +" (textClosureList arg); + + noDepEntry = text : {inherit text;}; + FullDepEntry = text : deps: {inherit text args;}; +}