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

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

54 lines
1.5 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 (lib.mdDoc "OpenRGB server");
package = mkOption {
type = types.package;
default = pkgs.openrgb;
defaultText = literalMD "pkgs.openrgb";
description = lib.mdDoc "Set version of openrgb package to use.";
};
motherboard = mkOption {
type = types.nullOr (types.enum [ "amd" "intel" ]);
default = null;
description = lib.mdDoc "CPU family of motherboard. Allows for addition motherboard i2c support.";
};
server.port = mkOption {
type = types.port;
default = 6742;
description = lib.mdDoc "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 = with lib.maintainers; [ jonringer ];
}