depot/third_party/nixpkgs/nixos/modules/services/hardware/usbrelayd.nix
Default email b450903751 Project import generated by Copybara.
GitOrigin-RevId: 74a1793c659d09d7cf738005308b1f86c90cb59b
2022-09-09 16:08:57 +02:00

47 lines
1,023 B
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.usbrelayd;
in
{
options.services.usbrelayd = with types; {
enable = mkEnableOption (lib.mdDoc "USB Relay MQTT daemon");
broker = mkOption {
type = str;
description = lib.mdDoc "Hostname or IP address of your MQTT Broker.";
default = "127.0.0.1";
example = [
"mqtt"
"192.168.1.1"
];
};
clientName = mkOption {
type = str;
description = lib.mdDoc "Name, your client connects as.";
default = "MyUSBRelay";
};
};
config = mkIf cfg.enable {
environment.etc."usbrelayd.conf".text = ''
[MQTT]
BROKER = ${cfg.broker}
CLIENTNAME = ${cfg.clientName}
'';
services.udev.packages = [ pkgs.usbrelayd ];
systemd.packages = [ pkgs.usbrelayd ];
users.users.usbrelay = {
isSystemUser = true;
group = "usbrelay";
};
users.groups.usbrelay = { };
};
meta = {
maintainers = with lib.maintainers; [ wentasah ];
};
}