nixos/lact: allow configuring declaratively

NotAShelf d0dd9e1c f8a7597f

Changed files
+29 -1
nixos
modules
services
hardware
+29 -1
nixos/modules/services/hardware/lact.nix
···
pkgs,
...
}:
-
let
cfg = config.services.lact;
in
{
meta.maintainers = [ lib.maintainers.johnrtitor ];
···
};
package = lib.mkPackageOption pkgs "lact" { };
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
systemd.packages = [ cfg.package ];
systemd.services.lactd = {
description = "LACT GPU Control Daemon";
wantedBy = [ "multi-user.target" ];
};
};
}
···
pkgs,
...
}:
let
cfg = config.services.lact;
+
configFormat = pkgs.formats.yaml { };
+
configFile = configFormat.generate "lact-config.yaml" cfg.settings;
in
{
meta.maintainers = [ lib.maintainers.johnrtitor ];
···
};
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 ];
};
};
}