1 { config, lib, pkgs, ... }:
6 cfg = config.services.ebusd;
11 "${package}/bin/ebusd"
14 "--device=${cfg.device}"
15 "--port=${toString cfg.port}"
16 "--configpath=${cfg.configpath}"
17 "--scanconfig=${cfg.scanconfig}"
18 "--log=main:${cfg.logs.main}"
19 "--log=network:${cfg.logs.network}"
20 "--log=bus:${cfg.logs.bus}"
21 "--log=update:${cfg.logs.update}"
22 "--log=other:${cfg.logs.other}"
23 "--log=all:${cfg.logs.all}"
24 ] ++ lib.optionals cfg.readonly [
26 ] ++ lib.optionals cfg.mqtt.enable [
27 "--mqtthost=${cfg.mqtt.host}"
28 "--mqttport=${toString cfg.mqtt.port}"
29 "--mqttuser=${cfg.mqtt.user}"
30 "--mqttpass=${cfg.mqtt.password}"
31 ] ++ lib.optionals cfg.mqtt.home-assistant [
32 "--mqttint=${package}/etc/ebusd/mqtt-hassio.cfg"
34 ] ++ lib.optionals cfg.mqtt.retain [
36 ] ++ cfg.extraArguments;
38 usesDev = hasPrefix "/" cfg.device;
40 command = concatStringsSep " " arguments;
44 meta.maintainers = with maintainers; [ nathan-gs ];
46 options.services.ebusd = {
47 enable = mkEnableOption (lib.mdDoc "ebusd service");
53 description = lib.mdDoc ''
54 Use DEV as eBUS device [/dev/ttyUSB0].
56 enh:DEVICE or enh:IP:PORT for enhanced device (only adapter v3 and newer),
57 ens:DEVICE for enhanced high speed serial device (only adapter v3 and newer with firmware since 20220731),
58 DEVICE for serial device (normal speed, for all other serial adapters like adapter v2 as well as adapter v3 in non-enhanced mode), or
59 [udp:]IP:PORT for network device.
60 https://github.com/john30/ebusd/wiki/2.-Run#device-options
67 description = lib.mdDoc ''
68 The port on which to listen on
75 description = lib.mdDoc ''
76 Only read from device, never write to it
80 configpath = mkOption {
82 default = "https://cfg.ebusd.eu/";
83 description = lib.mdDoc ''
84 Read CSV config files from PATH (local folder or HTTPS URL) [https://cfg.ebusd.eu/]
88 scanconfig = mkOption {
91 description = lib.mdDoc ''
92 Pick CSV config files matching initial scan ("none" or empty for no initial scan message, "full" for full scan, or a single hex address to scan, default is to send a broadcast ident message).
93 If combined with --checkconfig, you can add scan message data as arguments for checking a particular scan configuration, e.g. "FF08070400/0AB5454850303003277201". For further details on this option,
94 see [Automatic configuration](https://github.com/john30/ebusd/wiki/4.7.-Automatic-configuration).
100 type = types.enum [ "error" "notice" "info" "debug"];
102 description = lib.mdDoc ''
103 Only write log for matching AREAs (main|network|bus|update|other|all) below or equal to LEVEL (error|notice|info|debug) [all:notice].
108 type = types.enum [ "error" "notice" "info" "debug"];
110 description = lib.mdDoc ''
111 Only write log for matching AREAs (main|network|bus|update|other|all) below or equal to LEVEL (error|notice|info|debug) [all:notice].
116 type = types.enum [ "error" "notice" "info" "debug"];
118 description = lib.mdDoc ''
119 Only write log for matching AREAs (main|network|bus|update|other|all) below or equal to LEVEL (error|notice|info|debug) [all:notice].
124 type = types.enum [ "error" "notice" "info" "debug"];
126 description = lib.mdDoc ''
127 Only write log for matching AREAs (main|network|bus|update|other|all) below or equal to LEVEL (error|notice|info|debug) [all:notice].
132 type = types.enum [ "error" "notice" "info" "debug"];
134 description = lib.mdDoc ''
135 Only write log for matching AREAs (main|network|bus|update|other|all) below or equal to LEVEL (error|notice|info|debug) [all:notice].
140 type = types.enum [ "error" "notice" "info" "debug"];
142 description = lib.mdDoc ''
143 Only write log for matching AREAs (main|network|bus|update|other|all) below or equal to LEVEL (error|notice|info|debug) [all:notice].
153 description = lib.mdDoc ''
154 Adds support for MQTT
160 default = "localhost";
161 description = lib.mdDoc ''
162 Connect to MQTT broker on HOST.
169 description = lib.mdDoc ''
170 The port on which to connect to MQTT
174 home-assistant = mkOption {
177 description = lib.mdDoc ''
178 Adds the Home Assistant topics to MQTT, read more at [MQTT Integration](https://github.com/john30/ebusd/wiki/MQTT-integration)
185 description = lib.mdDoc ''
186 Set the retain flag on all topics instead of only selected global ones
192 description = lib.mdDoc ''
197 password = mkOption {
199 description = lib.mdDoc ''
206 extraArguments = mkOption {
207 type = types.listOf types.str;
209 description = lib.mdDoc ''
210 Extra arguments to the ebus daemon
216 config = mkIf (cfg.enable) {
218 systemd.services.ebusd = {
219 description = "EBUSd Service";
220 wantedBy = [ "multi-user.target" ];
221 after = [ "network.target" ];
225 Restart = "on-failure";
228 CapabilityBoundingSet = "";
229 DeviceAllow = lib.optionals usesDev [
232 DevicePolicy = "closed";
233 LockPersonality = true;
234 MemoryDenyWriteExecute = false;
235 NoNewPrivileges = true;
236 PrivateDevices = usesDev;
240 ProtectControlGroups = true;
242 ProtectHostname = true;
243 ProtectKernelLogs = true;
244 ProtectKernelModules = true;
245 ProtectKernelTunables = true;
246 ProtectProc = "invisible";
248 ProtectSystem = "strict";
250 RestrictAddressFamilies = [
254 RestrictNamespaces = true;
255 RestrictRealtime = true;
256 RestrictSUIDSGID = true;
257 SupplementaryGroups = [
260 SystemCallArchitectures = "native";
262 "@system-service @pkey"
263 "~@privileged @resources"