blob: 42b4218aa09442af099266cda149daac34ed7aed (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.services.domoticz;
pkgDesc = "Domoticz home automation";
in {
options = {
services.domoticz = {
enable = mkEnableOption pkgDesc;
user = mkOption {
type = types.str;
default = "domoticz";
description = "domoticz user";
};
group = mkOption {
type = types.str;
default = "domoticz";
description = "domoticz group";
};
extraGroups = mkOption {
type = types.listOf types.str;
default = [ ];
description = "Extra groups to add to domoticz user";
};
stateDir = mkOption {
type = types.path;
default = "/var/lib/domoticz/";
description = "The state directory for domoticz";
example = "/home/bob/.domoticz/";
};
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 {
users.users."domoticz" = {
name = cfg.user;
group = cfg.group;
extraGroups = cfg.extraGroups;
home = cfg.stateDir;
createHome = true;
description = pkgDesc;
};
users.groups."domoticz" = {
name = cfg.group;
};
systemd.services."domoticz" = {
description = pkgDesc;
wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" ];
serviceConfig = {
User = cfg.user;
Group = cfg.group;
Restart = "always";
ExecStart = ''
${pkgs.domoticz}/bin/domoticz -noupdates -www ${toString cfg.port} -wwwbind ${cfg.bind} -sslwww 0 -userdata ${cfg.stateDir} -approot ${pkgs.domoticz}/share/domoticz/ -pidfile /var/run/domoticz.pid
'';
};
};
};
}
|