1 { config, lib, pkgs, ... }:
6 cfg = config.services.ebusd;
9 meta.maintainers = with maintainers; [ nathan-gs ];
11 options.services.ebusd = {
12 enable = mkEnableOption "ebusd, a daemon for communication with eBUS heating systems";
14 package = mkPackageOption pkgs "ebusd" { };
21 Use DEV as eBUS device [/dev/ttyUSB0].
23 enh:DEVICE or enh:IP:PORT for enhanced device (only adapter v3 and newer),
24 ens:DEVICE for enhanced high speed serial device (only adapter v3 and newer with firmware since 20220731),
25 DEVICE for serial device (normal speed, for all other serial adapters like adapter v2 as well as adapter v3 in non-enhanced mode), or
26 [udp:]IP:PORT for network device.
28 Source: <https://github.com/john30/ebusd/wiki/2.-Run#device-options>
36 The port on which to listen on
44 Only read from device, never write to it
48 configpath = mkOption {
50 default = "https://cfg.ebusd.eu/";
52 Directory to read CSV config files from. This can be a local folder or a URL.
56 scanconfig = mkOption {
60 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).
61 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,
62 see [Automatic configuration](https://github.com/john30/ebusd/wiki/4.7.-Automatic-configuration).
67 # "all" must come first so it can be overridden by more specific areas
68 areas = [ "all" "main" "network" "bus" "update" "other" ];
69 levels = [ "none" "error" "notice" "info" "debug" ];
70 in listToAttrs (map (area: nameValuePair area (mkOption {
71 type = types.enum levels;
75 Only write log for matching `AREA`s (${concatStringsSep "|" areas}) below or equal to `LEVEL` (${concatStringsSep "|" levels})
80 enable = mkEnableOption "support for MQTT";
84 default = "localhost";
86 Connect to MQTT broker on HOST.
94 The port on which to connect to MQTT
98 home-assistant = mkOption {
102 Adds the Home Assistant topics to MQTT, read more at [MQTT Integration](https://github.com/john30/ebusd/wiki/MQTT-integration)
106 retain = mkEnableOption "set the retain flag on all topics instead of only selected global ones";
115 password = mkOption {
123 extraArguments = mkOption {
124 type = types.listOf types.str;
127 Extra arguments to the ebus daemon
133 usesDev = hasPrefix "/" cfg.device;
135 systemd.services.ebusd = {
136 description = "EBUSd Service";
137 wantedBy = [ "multi-user.target" ];
138 after = [ "network.target" ];
141 args = cli.toGNUCommandLineShell { optionValueSeparator = "="; } (foldr (a: b: a // b) { } [
143 inherit (cfg) device port configpath scanconfig readonly;
146 log = mapAttrsToList (name: value: "${name}:${value}") cfg.logs;
147 mqttretain = cfg.mqtt.retain;
149 (optionalAttrs cfg.mqtt.enable {
150 mqtthost = cfg.mqtt.host;
151 mqttport = cfg.mqtt.port;
152 mqttuser = cfg.mqtt.user;
153 mqttpass = cfg.mqtt.password;
155 (optionalAttrs cfg.mqtt.home-assistant {
156 mqttint = "${cfg.package}/etc/ebusd/mqtt-hassio.cfg";
160 in "${cfg.package}/bin/ebusd ${args} ${escapeShellArgs cfg.extraArguments}";
163 Restart = "on-failure";
166 CapabilityBoundingSet = "";
167 DeviceAllow = optionals usesDev [ cfg.device ];
168 DevicePolicy = "closed";
169 LockPersonality = true;
170 MemoryDenyWriteExecute = false;
171 NoNewPrivileges = true;
172 PrivateDevices = usesDev;
176 ProtectControlGroups = true;
178 ProtectHostname = true;
179 ProtectKernelLogs = true;
180 ProtectKernelModules = true;
181 ProtectKernelTunables = true;
182 ProtectProc = "invisible";
184 ProtectSystem = "strict";
186 RestrictAddressFamilies = [
190 RestrictNamespaces = true;
191 RestrictRealtime = true;
192 RestrictSUIDSGID = true;
193 SupplementaryGroups = [ "dialout" ];
194 SystemCallArchitectures = "native";
196 "@system-service @pkey"
197 "~@privileged @resources"