| 
									
										
										
										
											2024-05-16 11:39:01 -04:00
										 |  |  | { lib, ... }: | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2025-04-01 13:59:09 -04:00
										 |  |  |   # create adev namespace for lib | 
					
						
							|  |  |  |   adev = rec { | 
					
						
							| 
									
										
										
										
											2024-05-19 12:29:29 -04:00
										 |  |  |     systems = import ./systems.nix { inherit lib; }; | 
					
						
							| 
									
										
										
										
											2024-06-23 21:21:59 -04:00
										 |  |  |     container-utils = import ./container-utils.nix { inherit lib; }; | 
					
						
							| 
									
										
										
										
											2024-05-19 12:29:29 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-16 11:39:01 -04:00
										 |  |  |     # any(), but checks if any value in the list is true | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # args: | 
					
						
							|  |  |  |     # n: list of booleans | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # type: | 
					
						
							|  |  |  |     # anyBool:: [bool] -> bool | 
					
						
							|  |  |  |     anyBool = lib.any (n: n); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # pulls a value out of an attrset and converts it to a list | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # args: | 
					
						
							|  |  |  |     # attr: attribute to search for in an attrset | 
					
						
							|  |  |  |     # set: attrset to search | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # type: | 
					
						
							| 
									
										
										
										
											2024-05-19 16:04:57 -04:00
										 |  |  |     # mapGetAttr :: String -> AttrSet -> [Any] | 
					
						
							| 
									
										
										
										
											2024-05-21 19:43:57 -04:00
										 |  |  |     mapGetAttr = attr: set: lib.mapAttrsToList (_: attrset: lib.getAttr attr attrset) set; | 
					
						
							| 
									
										
										
										
											2024-05-16 11:39:01 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # gets list of files and directories inside of a directory | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # args: | 
					
						
							|  |  |  |     # base: base path to search | 
					
						
							|  |  |  |     # dir: directory to get files from | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # type: | 
					
						
							|  |  |  |     # ls :: Path -> String -> [String] | 
					
						
							| 
									
										
										
										
											2024-05-19 10:26:46 -04:00
										 |  |  |     ls = dir: lib.attrNames (builtins.readDir dir); | 
					
						
							| 
									
										
										
										
											2024-05-16 11:39:01 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # gets list of directories inside of a given directory | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # args: | 
					
						
							|  |  |  |     # base: base path to search | 
					
						
							|  |  |  |     # dir: directory to get files from | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # type: | 
					
						
							|  |  |  |     # lsdir :: Path -> String -> [String] | 
					
						
							|  |  |  |     lsdir = | 
					
						
							| 
									
										
										
										
											2024-05-19 10:26:46 -04:00
										 |  |  |       dir: | 
					
						
							| 
									
										
										
										
											2024-05-20 01:19:21 -04:00
										 |  |  |       lib.optionals (builtins.pathExists dir) ( | 
					
						
							| 
									
										
										
										
											2024-05-21 19:47:21 -04:00
										 |  |  |         lib.attrNames (lib.filterAttrs (_: type: type == "directory") (builtins.readDir dir)) | 
					
						
							| 
									
										
										
										
											2024-05-20 01:19:21 -04:00
										 |  |  |       ); | 
					
						
							| 
									
										
										
										
											2024-05-16 11:39:01 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # return full paths of all files in a directory | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # args: | 
					
						
							|  |  |  |     # base: base path to search | 
					
						
							|  |  |  |     # dir: path to get files from | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # type: | 
					
						
							|  |  |  |     # fileList :: Path -> String -> [Path] | 
					
						
							| 
									
										
										
										
											2024-05-19 10:26:46 -04:00
										 |  |  |     fileList = dir: map (file: dir + "/${file}") (ls dir); | 
					
						
							| 
									
										
										
										
											2024-06-22 01:20:26 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-16 08:59:15 -04:00
										 |  |  |     # reduce an attribute set to a string | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # example: | 
					
						
							|  |  |  |     # given attrset {host1 = "palatine-hill"; host2 = "jeeves";} | 
					
						
							|  |  |  |     # and func (host: hostname: host + " is " + hostname + ", " ) | 
					
						
							|  |  |  |     # mapAttrsToString would return 'host1 is palatine-hill, host2 is jeeves, ' | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # args: | 
					
						
							|  |  |  |     # func: an function to apply to attrSet to turn each entry into one string | 
					
						
							|  |  |  |     # attrSet: an attribute set to reduce | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # type: | 
					
						
							|  |  |  |     # mapAttrsToString :: AttrSet -> (String -> Any -> String) -> String | 
					
						
							|  |  |  |     mapAttrsToString = | 
					
						
							|  |  |  |       func: attrSet: (lib.foldl' (cur: next: cur + next) "" (lib.mapAttrsToList func attrSet)); | 
					
						
							| 
									
										
										
										
											2024-05-16 11:39:01 -04:00
										 |  |  |   }; | 
					
						
							|  |  |  | } |