1 { pkgs, lib, config, ... }:
6 cfg = config.services.hardware.openrgb;
8 options.services.hardware.openrgb = {
9 enable = mkEnableOption (lib.mdDoc "OpenRGB server");
13 default = pkgs.openrgb;
14 defaultText = literalMD "pkgs.openrgb";
15 description = lib.mdDoc "Set version of openrgb package to use.";
18 motherboard = mkOption {
19 type = types.nullOr (types.enum [ "amd" "intel" ]);
20 default = if config.hardware.cpu.intel.updateMicrocode then "intel"
21 else if config.hardware.cpu.amd.updateMicrocode then "amd"
23 defaultText = literalMD ''
24 if config.hardware.cpu.intel.updateMicrocode then "intel"
25 else if config.hardware.cpu.amd.updateMicrocode then "amd"
28 description = lib.mdDoc "CPU family of motherboard. Allows for addition motherboard i2c support.";
31 server.port = mkOption {
34 description = lib.mdDoc "Set server port of openrgb.";
39 config = mkIf cfg.enable {
40 environment.systemPackages = [ cfg.package ];
41 services.udev.packages = [ cfg.package ];
43 boot.kernelModules = [ "i2c-dev" ]
44 ++ lib.optionals (cfg.motherboard == "amd") [ "i2c-piix4" ]
45 ++ lib.optionals (cfg.motherboard == "intel") [ "i2c-i801" ];
47 systemd.services.openrgb = {
48 description = "OpenRGB server daemon";
49 wantedBy = [ "multi-user.target" ];
51 StateDirectory = "OpenRGB";
52 WorkingDirectory = "/var/lib/OpenRGB";
53 ExecStart = "${cfg.package}/bin/openrgb --server --server-port ${toString cfg.server.port}";
59 meta.maintainers = with lib.maintainers; [ jonringer ];