2021-12-30 19:55:51 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.services.hardware.openrgb;
|
|
|
|
in {
|
|
|
|
options.services.hardware.openrgb = {
|
2024-08-27 18:43:21 +00:00
|
|
|
enable = lib.mkEnableOption "OpenRGB server, for RGB lighting control";
|
2021-12-30 19:55:51 +00:00
|
|
|
|
2024-08-27 18:43:21 +00:00
|
|
|
package = lib.mkPackageOption pkgs "openrgb" { };
|
2021-12-30 19:55:51 +00:00
|
|
|
|
2024-08-27 18:43:21 +00:00
|
|
|
motherboard = lib.mkOption {
|
|
|
|
type = lib.types.nullOr (lib.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;
|
2024-08-27 18:43:21 +00:00
|
|
|
defaultText = lib.literalMD ''
|
2023-09-03 05:13:40 +00:00
|
|
|
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.";
|
|
|
|
};
|
|
|
|
|
2024-08-27 18:43:21 +00:00
|
|
|
server.port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
2021-12-30 19:55:51 +00:00
|
|
|
default = 6742;
|
|
|
|
description = "Set server port of openrgb.";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2024-08-27 18:43:21 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2021-12-30 19:55:51 +00:00
|
|
|
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
|
|
|
}
|