2020-04-30 12:51:49 +01:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.domoticz;
|
|
|
|
pkgDesc = "Domoticz home automation";
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.domoticz = {
|
2024-08-24 22:05:42 +02:00
|
|
|
enable = lib.mkEnableOption pkgDesc;
|
2020-04-30 12:51:49 +01:00
|
|
|
|
2024-08-24 22:05:42 +02:00
|
|
|
bind = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2020-04-30 12:51:49 +01:00
|
|
|
default = "0.0.0.0";
|
|
|
|
description = "IP address to bind to.";
|
|
|
|
};
|
|
|
|
|
2024-08-24 22:05:42 +02:00
|
|
|
port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
2020-04-30 12:51:49 +01:00
|
|
|
default = 8080;
|
|
|
|
description = "Port to bind to for HTTP, set to 0 to disable HTTP.";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2024-08-24 22:05:42 +02:00
|
|
|
config = lib.mkIf cfg.enable {
|
2020-04-30 12:51:49 +01:00
|
|
|
|
|
|
|
systemd.services."domoticz" = {
|
|
|
|
description = pkgDesc;
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2023-10-03 22:21:50 -07:00
|
|
|
wants = [ "network-online.target" ];
|
2020-04-30 12:51:49 +01:00
|
|
|
after = [ "network-online.target" ];
|
|
|
|
serviceConfig = {
|
2020-10-10 08:03:11 -07:00
|
|
|
DynamicUser = true;
|
|
|
|
StateDirectory = "domoticz";
|
2020-04-30 12:51:49 +01:00
|
|
|
Restart = "always";
|
|
|
|
ExecStart = ''
|
2020-10-10 08:03:11 -07:00
|
|
|
${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
|
2020-04-30 12:51:49 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|