8 cfg = config.services.ebusd;
11 meta.maintainers = with lib.maintainers; [ nathan-gs ];
13 options.services.ebusd = {
14 enable = lib.mkEnableOption "ebusd, a daemon for communication with eBUS heating systems";
16 package = lib.mkPackageOption pkgs "ebusd" { };
18 device = lib.mkOption {
23 Use DEV as eBUS device [/dev/ttyUSB0].
25 enh:DEVICE or enh:IP:PORT for enhanced device (only adapter v3 and newer),
26 ens:DEVICE for enhanced high speed serial device (only adapter v3 and newer with firmware since 20220731),
27 DEVICE for serial device (normal speed, for all other serial adapters like adapter v2 as well as adapter v3 in non-enhanced mode), or
28 [udp:]IP:PORT for network device.
30 Source: <https://github.com/john30/ebusd/wiki/2.-Run#device-options>
36 type = lib.types.port;
38 The port on which to listen on
42 readonly = lib.mkOption {
43 type = lib.types.bool;
46 Only read from device, never write to it
50 configpath = lib.mkOption {
52 default = "https://cfg.ebusd.eu/";
54 Directory to read CSV config files from. This can be a local folder or a URL.
58 scanconfig = lib.mkOption {
62 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).
63 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,
64 see [Automatic configuration](https://github.com/john30/ebusd/wiki/4.7.-Automatic-configuration).
70 # "all" must come first so it can be overridden by more specific areas
90 lib.nameValuePair area (
92 type = lib.types.enum levels;
96 Only write log for matching `AREA`s (${lib.concatStringsSep "|" areas}) below or equal to `LEVEL` (${lib.concatStringsSep "|" levels})
104 enable = lib.mkEnableOption "support for MQTT";
106 host = lib.mkOption {
107 type = lib.types.str;
108 default = "localhost";
110 Connect to MQTT broker on HOST.
114 port = lib.mkOption {
116 type = lib.types.port;
118 The port on which to connect to MQTT
122 home-assistant = lib.mkOption {
123 type = lib.types.bool;
126 Adds the Home Assistant topics to MQTT, read more at [MQTT Integration](https://github.com/john30/ebusd/wiki/MQTT-integration)
130 retain = lib.mkEnableOption "set the retain flag on all topics instead of only selected global ones";
132 user = lib.mkOption {
133 type = lib.types.str;
139 password = lib.mkOption {
140 type = lib.types.str;
147 extraArguments = lib.mkOption {
148 type = lib.types.listOf lib.types.str;
151 Extra arguments to the ebus daemon
158 usesDev = lib.any (prefix: lib.hasPrefix prefix cfg.device) [
164 lib.mkIf cfg.enable {
165 systemd.services.ebusd = {
166 description = "EBUSd Service";
167 wantedBy = [ "multi-user.target" ];
168 after = [ "network.target" ];
172 args = lib.cli.toGNUCommandLineShell { optionValueSeparator = "="; } (
173 lib.foldr (a: b: a // b) { } [
184 log = lib.mapAttrsToList (name: value: "${name}:${value}") cfg.logs;
185 mqttretain = cfg.mqtt.retain;
187 (lib.optionalAttrs cfg.mqtt.enable {
188 mqtthost = cfg.mqtt.host;
189 mqttport = cfg.mqtt.port;
190 mqttuser = cfg.mqtt.user;
191 mqttpass = cfg.mqtt.password;
193 (lib.optionalAttrs cfg.mqtt.home-assistant {
194 mqttint = "${cfg.package}/etc/ebusd/mqtt-hassio.cfg";
200 "${cfg.package}/bin/ebusd ${args} ${lib.escapeShellArgs cfg.extraArguments}";
203 Restart = "on-failure";
206 CapabilityBoundingSet = "";
207 DeviceAllow = lib.optionals usesDev [
208 (lib.removePrefix "ens:" (lib.removePrefix "enh:" cfg.device))
210 DevicePolicy = "closed";
211 LockPersonality = true;
212 MemoryDenyWriteExecute = false;
213 NoNewPrivileges = true;
214 PrivateDevices = !usesDev;
218 ProtectControlGroups = true;
220 ProtectHostname = true;
221 ProtectKernelLogs = true;
222 ProtectKernelModules = true;
223 ProtectKernelTunables = true;
224 ProtectProc = "invisible";
226 ProtectSystem = "strict";
228 RestrictAddressFamilies = [
232 RestrictNamespaces = true;
233 RestrictRealtime = true;
234 RestrictSUIDSGID = true;
235 SupplementaryGroups = [ "dialout" ];
236 SystemCallArchitectures = "native";
238 "@system-service @pkey"
239 "~@privileged @resources"