forked from fabian/nix
		
	doctrine/lib: refactor 'close' helper
This commit is contained in:
		
							parent
							
								
									a8ef8e43b9
								
							
						
					
					
						commit
						2fe1f36eb9
					
				
					 3 changed files with 20 additions and 13 deletions
				
			
		|  | @ -3,8 +3,18 @@ | ||||||
|   doctrine, |   doctrine, | ||||||
|   pkgs, |   pkgs, | ||||||
| }: let | }: let | ||||||
|   close = f: args: f (args // {inherit lib pkgs doctrine;}); |   close = vars: f: args: | ||||||
|  |     ( | ||||||
|  |       if builtins.isPath f | ||||||
|  |       then import f | ||||||
|  |       else f | ||||||
|  |     ) | ||||||
|  |     (args // vars); | ||||||
|  | 
 | ||||||
|  |   closeLib = close {inherit lib;}; | ||||||
|  |   closeFull = close {inherit lib pkgs doctrine;}; | ||||||
| in { | in { | ||||||
|   importAll = pkgs.callPackage ./importAll.nix {}; |   inherit close; | ||||||
|   mkModule = close (import ./mk-module.nix); |   importAll = closeLib ./importAll.nix; | ||||||
|  |   mkModule = closeFull ./mk-module.nix; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,4 +1,5 @@ | ||||||
| {lib}: { | { | ||||||
|  |   lib, | ||||||
|   root, |   root, | ||||||
|   exclude ? ["default"], |   exclude ? ["default"], | ||||||
| }: | }: | ||||||
|  |  | ||||||
|  | @ -26,13 +26,9 @@ in { | ||||||
|     lib.optionalAttrs (configFiles ? ${doctrine.namespace}) |     lib.optionalAttrs (configFiles ? ${doctrine.namespace}) | ||||||
|     (lib.mkIf cfg.enable configSet); |     (lib.mkIf cfg.enable configSet); | ||||||
| 
 | 
 | ||||||
|   options = lib.optionalAttrs (options |   options.${doctrine.prefix}.${name} = | ||||||
|     != null |     lib.optionalAttrs (options != null && optionsSet ? ${doctrine.namespace}) optionsSet.${doctrine.namespace} | ||||||
|     && optionsSet ? ${doctrine.namespace}) { |     // { | ||||||
|     ${doctrine.prefix}.${name} = |       enable = lib.mkEnableOption name; | ||||||
|       optionsSet.${doctrine.namespace} |     }; | ||||||
|       // { |  | ||||||
|         enable = lib.mkEnableOption name; |  | ||||||
|       }; |  | ||||||
|   }; |  | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alejandro Soto
						Alejandro Soto