2022-03-29 22:54:42 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.usbrelayd;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.services.usbrelayd = with types; {
|
|
|
|
enable = mkEnableOption "USB Relay MQTT daemon";
|
|
|
|
|
|
|
|
broker = mkOption {
|
|
|
|
type = str;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Hostname or IP address of your MQTT Broker.";
|
2022-03-29 22:54:42 +01:00
|
|
|
default = "127.0.0.1";
|
|
|
|
example = [
|
|
|
|
"mqtt"
|
|
|
|
"192.168.1.1"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
clientName = mkOption {
|
|
|
|
type = str;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Name, your client connects as.";
|
2022-03-29 22:54:42 +01:00
|
|
|
default = "MyUSBRelay";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2022-05-08 20:16:32 +01:00
|
|
|
environment.etc."usbrelayd.conf".text = ''
|
2022-03-29 22:54:42 +01:00
|
|
|
[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 = { };
|
|
|
|
};
|
2022-05-08 20:43:37 +01:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
maintainers = with lib.maintainers; [ wentasah ];
|
|
|
|
};
|
2022-03-29 22:54:42 +01:00
|
|
|
}
|