nixpkgs/nixos/modules/services/hardware/openrgb.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.6 KiB
Nix
Raw Normal View History

2021-12-30 19:55:51 +00:00
{ pkgs, lib, config, ... }:
with lib;
let
cfg = config.services.hardware.openrgb;
in {
options.services.hardware.openrgb = {
enable = mkEnableOption "OpenRGB server, for RGB lighting control";
2021-12-30 19:55:51 +00:00
package = mkPackageOption pkgs "openrgb" { };
2021-12-30 19:55:51 +00:00
motherboard = mkOption {
type = types.nullOr (types.enum [ "amd" "intel" ]);
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";
};
};
};
meta.maintainers = [ ];
2021-12-30 19:55:51 +00:00
}