2022-04-27 09:35:20 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.usbrelayd;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.services.usbrelayd = with types; {
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = mkEnableOption "USB Relay MQTT daemon";
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
|
|
broker = mkOption {
|
|
|
|
type = str;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Hostname or IP address of your MQTT Broker.";
|
2022-04-27 09:35:20 +00:00
|
|
|
default = "127.0.0.1";
|
|
|
|
example = [
|
|
|
|
"mqtt"
|
|
|
|
"192.168.1.1"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
clientName = mkOption {
|
|
|
|
type = str;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Name, your client connects as.";
|
2022-04-27 09:35:20 +00:00
|
|
|
default = "MyUSBRelay";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
environment.etc."usbrelayd.conf".text = ''
|
2022-04-27 09:35:20 +00:00
|
|
|
[MQTT]
|
|
|
|
BROKER = ${cfg.broker}
|
|
|
|
CLIENTNAME = ${cfg.clientName}
|
|
|
|
'';
|
|
|
|
|
|
|
|
services.udev.packages = [ pkgs.usbrelayd ];
|
|
|
|
systemd.packages = [ pkgs.usbrelayd ];
|
|
|
|
users.groups.usbrelay = { };
|
|
|
|
};
|
2022-05-18 14:49:53 +00:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
maintainers = with lib.maintainers; [ wentasah ];
|
|
|
|
};
|
2022-04-27 09:35:20 +00:00
|
|
|
}
|