| 
									
										
										
										
											2017-10-25 15:35:45 +02:00
										 |  |  | # This derivation builds two files containing information about the | 
					
						
							|  |  |  | # closure of 'rootPaths': $out/store-paths contains the paths in the | 
					
						
							|  |  |  | # closure, and $out/registration contains a file suitable for use with | 
					
						
							|  |  |  | # "nix-store --load-db" and "nix-store --register-validity | 
					
						
							|  |  |  | # --hash-given". | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-08 13:56:54 +01:00
										 |  |  | { stdenv, coreutils, jq }: | 
					
						
							| 
									
										
										
										
											2017-10-25 15:35:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | { rootPaths }: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 15:47:19 +01:00
										 |  |  | assert builtins.langVersion >= 5; | 
					
						
							| 
									
										
										
										
											2017-10-25 15:35:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 15:47:19 +01:00
										 |  |  | stdenv.mkDerivation { | 
					
						
							|  |  |  |   name = "closure-info"; | 
					
						
							| 
									
										
										
										
											2017-10-25 15:35:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 15:47:19 +01:00
										 |  |  |   __structuredAttrs = true; | 
					
						
							| 
									
										
										
										
											2017-10-25 15:35:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 15:47:19 +01:00
										 |  |  |   exportReferencesGraph.closure = rootPaths; | 
					
						
							| 
									
										
										
										
											2017-10-25 15:35:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 15:47:19 +01:00
										 |  |  |   PATH = "${coreutils}/bin:${jq}/bin"; | 
					
						
							| 
									
										
										
										
											2017-10-25 15:35:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 15:47:19 +01:00
										 |  |  |   builder = builtins.toFile "builder" | 
					
						
							|  |  |  |     ''
 | 
					
						
							|  |  |  |       if [ -e .attrs.sh ]; then . .attrs.sh; fi | 
					
						
							| 
									
										
										
										
											2017-10-25 15:35:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 15:47:19 +01:00
										 |  |  |       out=''${outputs[out]}
 | 
					
						
							| 
									
										
										
										
											2017-10-25 15:35:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 15:47:19 +01:00
										 |  |  |       mkdir $out | 
					
						
							| 
									
										
										
										
											2017-10-25 15:35:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-23 10:52:37 -05:00
										 |  |  |       jq -r ".closure | map(.narSize) | add" < .attrs.json > $out/total-nar-size | 
					
						
							| 
									
										
										
										
											2018-02-07 15:47:19 +01:00
										 |  |  |       jq -r '.closure | map([.path, .narHash, .narSize, "", (.references | length)] + .references) | add | map("\(.)\n") | add' < .attrs.json | head -n -1 > $out/registration | 
					
						
							|  |  |  |       jq -r .closure[].path < .attrs.json > $out/store-paths | 
					
						
							|  |  |  |     '';
 | 
					
						
							|  |  |  | } |