1{
2 lib,
3 pkgs,
4 config,
5 ...
6}:
7let
8
9 cfg = config.services.domoticz;
10 pkgDesc = "Domoticz home automation";
11
12in
13{
14
15 options = {
16
17 services.domoticz = {
18 enable = lib.mkEnableOption pkgDesc;
19
20 bind = lib.mkOption {
21 type = lib.types.str;
22 default = "0.0.0.0";
23 description = "IP address to bind to.";
24 };
25
26 port = lib.mkOption {
27 type = lib.types.port;
28 default = 8080;
29 description = "Port to bind to for HTTP, set to 0 to disable HTTP.";
30 };
31
32 };
33
34 };
35
36 config = lib.mkIf cfg.enable {
37
38 systemd.services."domoticz" = {
39 description = pkgDesc;
40 wantedBy = [ "multi-user.target" ];
41 wants = [ "network-online.target" ];
42 after = [ "network-online.target" ];
43 serviceConfig = {
44 DynamicUser = true;
45 StateDirectory = "domoticz";
46 Restart = "always";
47 ExecStart = ''
48 ${pkgs.domoticz}/bin/domoticz -noupdates -www ${toString cfg.port} -wwwbind ${cfg.bind} -sslwww 0 -userdata /var/lib/domoticz -approot ${pkgs.domoticz}/share/domoticz/ -pidfile /var/run/domoticz.pid
49 '';
50 };
51 };
52
53 };
54
55}