git-subtree-dir: trivionomicon git-subtree-mainline:00d3799f90git-subtree-split:0ae8676d50
		
			
				
	
	
		
			51 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
{
 | 
						|
  # The first few arguments are implicitly passed by the 'close' helper
 | 
						|
  lib,
 | 
						|
  pkgs,
 | 
						|
  doctrine,
 | 
						|
  name,
 | 
						|
  config,
 | 
						|
  hm ? null,
 | 
						|
  sys ? null,
 | 
						|
  options ? null,
 | 
						|
  requires ? [],
 | 
						|
  prefix ? doctrine.prefix,
 | 
						|
  namespace ? doctrine.namespace,
 | 
						|
  passthru ? {},
 | 
						|
}: let
 | 
						|
  optionsSet = import options (passthru
 | 
						|
    // {
 | 
						|
      inherit config lib pkgs cfg name doctrine;
 | 
						|
    });
 | 
						|
 | 
						|
  configSet = import configFiles.${namespace} (passthru
 | 
						|
    // {
 | 
						|
      inherit config lib pkgs doctrine cfg;
 | 
						|
    });
 | 
						|
 | 
						|
  configFiles = lib.filterAttrs (k: v: v != null) {
 | 
						|
    inherit sys hm;
 | 
						|
  };
 | 
						|
 | 
						|
  cfg = config.${prefix}.${name};
 | 
						|
in {
 | 
						|
  config =
 | 
						|
    lib.optionalAttrs (configFiles ? ${namespace})
 | 
						|
    (lib.mkIf cfg.enable (lib.mkMerge [
 | 
						|
      configSet
 | 
						|
      {
 | 
						|
        assertions =
 | 
						|
          map (dependency: {
 | 
						|
            assertion = cfg.enable -> config.${prefix}.${dependency}.enable;
 | 
						|
            message = "${prefix}.${name}.enable requires ${prefix}.${dependency}.enable";
 | 
						|
          })
 | 
						|
          requires;
 | 
						|
      }
 | 
						|
    ]));
 | 
						|
 | 
						|
  options.${prefix}.${name} =
 | 
						|
    lib.optionalAttrs (options != null && optionsSet ? ${namespace}) optionsSet.${namespace}
 | 
						|
    // {
 | 
						|
      enable = lib.mkEnableOption name;
 | 
						|
    };
 | 
						|
}
 |