about summary refs log tree commit diff
path: root/pkgs/lib/strings-with-deps.nix
blob: 5f6cafaa67ad110076ccf752f94632fb2b8463c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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;};
}