at 24.11-pre 1.7 kB view raw
1{ pkgs, lib, config, ... }: 2 3with lib; 4 5let 6 cfg = config.services.hardware.openrgb; 7in { 8 options.services.hardware.openrgb = { 9 enable = mkEnableOption "OpenRGB server, for RGB lighting control"; 10 11 package = mkPackageOption pkgs "openrgb" { }; 12 13 motherboard = mkOption { 14 type = types.nullOr (types.enum [ "amd" "intel" ]); 15 default = if config.hardware.cpu.intel.updateMicrocode then "intel" 16 else if config.hardware.cpu.amd.updateMicrocode then "amd" 17 else null; 18 defaultText = literalMD '' 19 if config.hardware.cpu.intel.updateMicrocode then "intel" 20 else if config.hardware.cpu.amd.updateMicrocode then "amd" 21 else null; 22 ''; 23 description = "CPU family of motherboard. Allows for addition motherboard i2c support."; 24 }; 25 26 server.port = mkOption { 27 type = types.port; 28 default = 6742; 29 description = "Set server port of openrgb."; 30 }; 31 32 }; 33 34 config = mkIf cfg.enable { 35 environment.systemPackages = [ cfg.package ]; 36 services.udev.packages = [ cfg.package ]; 37 38 boot.kernelModules = [ "i2c-dev" ] 39 ++ lib.optionals (cfg.motherboard == "amd") [ "i2c-piix4" ] 40 ++ lib.optionals (cfg.motherboard == "intel") [ "i2c-i801" ]; 41 42 systemd.services.openrgb = { 43 description = "OpenRGB server daemon"; 44 wantedBy = [ "multi-user.target" ]; 45 serviceConfig = { 46 StateDirectory = "OpenRGB"; 47 WorkingDirectory = "/var/lib/OpenRGB"; 48 ExecStart = "${cfg.package}/bin/openrgb --server --server-port ${toString cfg.server.port}"; 49 Restart = "always"; 50 }; 51 }; 52 }; 53 54 meta.maintainers = with lib.maintainers; [ jonringer ]; 55}