1 { pkgs, lib, config, ... }:
3 cfg = config.services.hardware.openrgb;
5 options.services.hardware.openrgb = {
6 enable = lib.mkEnableOption "OpenRGB server, for RGB lighting control";
8 package = lib.mkPackageOption pkgs "openrgb" { };
10 motherboard = lib.mkOption {
11 type = lib.types.nullOr (lib.types.enum [ "amd" "intel" ]);
12 default = if config.hardware.cpu.intel.updateMicrocode then "intel"
13 else if config.hardware.cpu.amd.updateMicrocode then "amd"
15 defaultText = lib.literalMD ''
16 if config.hardware.cpu.intel.updateMicrocode then "intel"
17 else if config.hardware.cpu.amd.updateMicrocode then "amd"
20 description = "CPU family of motherboard. Allows for addition motherboard i2c support.";
23 server.port = lib.mkOption {
24 type = lib.types.port;
26 description = "Set server port of openrgb.";
31 config = lib.mkIf cfg.enable {
32 environment.systemPackages = [ cfg.package ];
33 services.udev.packages = [ cfg.package ];
35 boot.kernelModules = [ "i2c-dev" ]
36 ++ lib.optionals (cfg.motherboard == "amd") [ "i2c-piix4" ]
37 ++ lib.optionals (cfg.motherboard == "intel") [ "i2c-i801" ];
39 systemd.services.openrgb = {
40 description = "OpenRGB server daemon";
41 wantedBy = [ "multi-user.target" ];
43 StateDirectory = "OpenRGB";
44 WorkingDirectory = "/var/lib/OpenRGB";
45 ExecStart = "${cfg.package}/bin/openrgb --server --server-port ${toString cfg.server.port}";
51 meta.maintainers = [ ];