nixos/lact: allow configuring declaratively
This commit is contained in:
		
							parent
							
								
									f8a7597f5d
								
							
						
					
					
						commit
						d0dd9e1c3a
					
				| @ -4,9 +4,10 @@ | ||||
|   pkgs, | ||||
|   ... | ||||
| }: | ||||
| 
 | ||||
| let | ||||
|   cfg = config.services.lact; | ||||
|   configFormat = pkgs.formats.yaml { }; | ||||
|   configFile = configFormat.generate "lact-config.yaml" cfg.settings; | ||||
| in | ||||
| { | ||||
|   meta.maintainers = [ lib.maintainers.johnrtitor ]; | ||||
| @ -25,15 +26,42 @@ in | ||||
|     }; | ||||
| 
 | ||||
|     package = lib.mkPackageOption pkgs "lact" { }; | ||||
| 
 | ||||
|     settings = lib.mkOption { | ||||
|       default = { }; | ||||
|       type = lib.types.submodule { | ||||
|         freeformType = configFormat.type; | ||||
|       }; | ||||
| 
 | ||||
|       description = '' | ||||
|         Settings for LACT. | ||||
| 
 | ||||
|         The easiest method of acquiring the settings is to delete | ||||
|         {file}`/etc/lact/config.yaml`, enter your settings and look | ||||
|         at the file. | ||||
| 
 | ||||
|         ::: {.note} | ||||
|         When `settings` is populated, the config file will be a symbolic link | ||||
|         and thus LACT daemon will not be able to modify it through the GUI. | ||||
|         ::: | ||||
|       ''; | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
|   config = lib.mkIf cfg.enable { | ||||
|     environment.systemPackages = [ cfg.package ]; | ||||
|     systemd.packages = [ cfg.package ]; | ||||
| 
 | ||||
|     environment.etc."lact/config.yaml" = lib.mkIf (cfg.settings != { }) { | ||||
|       source = configFile; | ||||
|     }; | ||||
| 
 | ||||
|     systemd.services.lactd = { | ||||
|       description = "LACT GPU Control Daemon"; | ||||
|       wantedBy = [ "multi-user.target" ]; | ||||
| 
 | ||||
|       # Restart when the config file changes. | ||||
|       restartTriggers = lib.mkIf (cfg.settings != { }) [ configFile ]; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 NotAShelf
						NotAShelf