forked from fabian/nix
		
	doctrine/lib: add optional prefix/namespace args to mkModule
This commit is contained in:
		
							parent
							
								
									3121013376
								
							
						
					
					
						commit
						4a7e6f545c
					
				
					 1 changed files with 9 additions and 7 deletions
				
			
		|  | @ -9,12 +9,14 @@ | ||||||
|   sys ? null, |   sys ? null, | ||||||
|   options ? null, |   options ? null, | ||||||
|   requires ? [], |   requires ? [], | ||||||
|  |   prefix ? doctrine.prefix, | ||||||
|  |   namespace ? doctrine.namespace, | ||||||
| }: let | }: let | ||||||
|   optionsSet = import options { |   optionsSet = import options { | ||||||
|     inherit config lib pkgs cfg name doctrine; |     inherit config lib pkgs cfg name doctrine; | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   configSet = import configFiles.${doctrine.namespace} { |   configSet = import configFiles.${namespace} { | ||||||
|     inherit config lib pkgs doctrine cfg; |     inherit config lib pkgs doctrine cfg; | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|  | @ -22,24 +24,24 @@ | ||||||
|     inherit sys hm; |     inherit sys hm; | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   cfg = config.${doctrine.prefix}.${name}; |   cfg = config.${prefix}.${name}; | ||||||
| in { | in { | ||||||
|   config = |   config = | ||||||
|     lib.optionalAttrs (configFiles ? ${doctrine.namespace}) |     lib.optionalAttrs (configFiles ? ${namespace}) | ||||||
|     (lib.mkIf cfg.enable (lib.mkMerge [ |     (lib.mkIf cfg.enable (lib.mkMerge [ | ||||||
|       configSet |       configSet | ||||||
|       { |       { | ||||||
|         assertions = |         assertions = | ||||||
|           map (dependency: { |           map (dependency: { | ||||||
|             assertion = cfg.enable -> config.${doctrine.prefix}.${dependency}.enable; |             assertion = cfg.enable -> config.${prefix}.${dependency}.enable; | ||||||
|             message = "${doctrine.prefix}.${name}.enable requires ${doctrine.prefix}.${dependency}.enable"; |             message = "${prefix}.${name}.enable requires ${prefix}.${dependency}.enable"; | ||||||
|           }) |           }) | ||||||
|           requires; |           requires; | ||||||
|       } |       } | ||||||
|     ])); |     ])); | ||||||
| 
 | 
 | ||||||
|   options.${doctrine.prefix}.${name} = |   options.${prefix}.${name} = | ||||||
|     lib.optionalAttrs (options != null && optionsSet ? ${doctrine.namespace}) optionsSet.${doctrine.namespace} |     lib.optionalAttrs (options != null && optionsSet ? ${namespace}) optionsSet.${namespace} | ||||||
|     // { |     // { | ||||||
|       enable = lib.mkEnableOption name; |       enable = lib.mkEnableOption name; | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alejandro Soto
						Alejandro Soto