summary refs log tree commit diff
path: root/nixos/modules/services/misc/domoticz.nix
blob: b1353d484048fd4174192a400534c4b86478d2c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ lib, pkgs, config, ... }:

with lib;

let

  cfg = config.services.domoticz;
  pkgDesc = "Domoticz home automation";

in {

  options = {

    services.domoticz = {
      enable = mkEnableOption pkgDesc;

      bind = mkOption {
        type = types.str;
        default = "0.0.0.0";
        description = "IP address to bind to.";
      };

      port = mkOption {
        type = types.int;
        default = 8080;
        description = "Port to bind to for HTTP, set to 0 to disable HTTP.";
      };

    };

  };

  config = mkIf cfg.enable {

    systemd.services."domoticz" = {
      description = pkgDesc;
      wantedBy = [ "multi-user.target" ];
      after = [ "network-online.target" ];
      serviceConfig = {
        DynamicUser = true;
        StateDirectory = "domoticz";
        Restart = "always";
        ExecStart = ''
          ${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
        '';
      };
    };

  };

}