2021-12-30 19:55:51 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.hardware.openrgb;
|
|
|
|
in {
|
|
|
|
options.services.hardware.openrgb = {
|
2023-10-18 12:08:30 +00:00
|
|
|
enable = mkEnableOption "OpenRGB server, for RGB lighting control";
|
2021-12-30 19:55:51 +00:00
|
|
|
|
2023-11-27 00:19:27 +00:00
|
|
|
package = mkPackageOption pkgs "openrgb" { };
|
2021-12-30 19:55:51 +00:00
|
|
|
|
|
|
|
motherboard = mkOption {
|
|
|
|
type = types.nullOr (types.enum [ "amd" "intel" ]);
|
2023-09-03 05:13:40 +00:00
|
|
|
default = if config.hardware.cpu.intel.updateMicrocode then "intel"
|
|
|
|
else if config.hardware.cpu.amd.updateMicrocode then "amd"
|
|
|
|
else null;
|
|
|
|
defaultText = literalMD ''
|
|
|
|
if config.hardware.cpu.intel.updateMicrocode then "intel"
|
|
|
|
else if config.hardware.cpu.amd.updateMicrocode then "amd"
|
|
|
|
else null;
|
|
|
|
'';
|
2021-12-30 19:55:51 +00:00
|
|
|
description = "CPU family of motherboard. Allows for addition motherboard i2c support.";
|
|
|
|
};
|
|
|
|
|
|
|
|
server.port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 6742;
|
|
|
|
description = "Set server port of openrgb.";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
services.udev.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
boot.kernelModules = [ "i2c-dev" ]
|
2023-05-09 13:34:21 +00:00
|
|
|
++ lib.optionals (cfg.motherboard == "amd") [ "i2c-piix4" ]
|
2021-12-30 19:55:51 +00:00
|
|
|
++ lib.optionals (cfg.motherboard == "intel") [ "i2c-i801" ];
|
|
|
|
|
|
|
|
systemd.services.openrgb = {
|
|
|
|
description = "OpenRGB server daemon";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
2023-05-09 13:34:21 +00:00
|
|
|
StateDirectory = "OpenRGB";
|
|
|
|
WorkingDirectory = "/var/lib/OpenRGB";
|
2021-12-30 19:55:51 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/openrgb --server --server-port ${toString cfg.server.port}";
|
|
|
|
Restart = "always";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-07-28 14:44:11 +00:00
|
|
|
meta.maintainers = [ ];
|
2021-12-30 19:55:51 +00:00
|
|
|
}
|