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, | ||||
|   options ? null, | ||||
|   requires ? [], | ||||
|   prefix ? doctrine.prefix, | ||||
|   namespace ? doctrine.namespace, | ||||
| }: let | ||||
|   optionsSet = import options { | ||||
|     inherit config lib pkgs cfg name doctrine; | ||||
|   }; | ||||
| 
 | ||||
|   configSet = import configFiles.${doctrine.namespace} { | ||||
|   configSet = import configFiles.${namespace} { | ||||
|     inherit config lib pkgs doctrine cfg; | ||||
|   }; | ||||
| 
 | ||||
|  | @ -22,24 +24,24 @@ | |||
|     inherit sys hm; | ||||
|   }; | ||||
| 
 | ||||
|   cfg = config.${doctrine.prefix}.${name}; | ||||
|   cfg = config.${prefix}.${name}; | ||||
| in { | ||||
|   config = | ||||
|     lib.optionalAttrs (configFiles ? ${doctrine.namespace}) | ||||
|     lib.optionalAttrs (configFiles ? ${namespace}) | ||||
|     (lib.mkIf cfg.enable (lib.mkMerge [ | ||||
|       configSet | ||||
|       { | ||||
|         assertions = | ||||
|           map (dependency: { | ||||
|             assertion = cfg.enable -> config.${doctrine.prefix}.${dependency}.enable; | ||||
|             message = "${doctrine.prefix}.${name}.enable requires ${doctrine.prefix}.${dependency}.enable"; | ||||
|             assertion = cfg.enable -> config.${prefix}.${dependency}.enable; | ||||
|             message = "${prefix}.${name}.enable requires ${prefix}.${dependency}.enable"; | ||||
|           }) | ||||
|           requires; | ||||
|       } | ||||
|     ])); | ||||
| 
 | ||||
|   options.${doctrine.prefix}.${name} = | ||||
|     lib.optionalAttrs (options != null && optionsSet ? ${doctrine.namespace}) optionsSet.${doctrine.namespace} | ||||
|   options.${prefix}.${name} = | ||||
|     lib.optionalAttrs (options != null && optionsSet ? ${namespace}) optionsSet.${namespace} | ||||
|     // { | ||||
|       enable = lib.mkEnableOption name; | ||||
|     }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alejandro Soto
						Alejandro Soto