diff --git a/nixos/modules/services/hardware/lact.nix b/nixos/modules/services/hardware/lact.nix index e16712338ab8..e797892b585f 100644 --- a/nixos/modules/services/hardware/lact.nix +++ b/nixos/modules/services/hardware/lact.nix @@ -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 ]; }; }; }