at 23.11-pre 1.1 kB view raw
1{ lib, pkgs, config, ... }: 2 3with lib; 4 5let 6 7 cfg = config.services.domoticz; 8 pkgDesc = "Domoticz home automation"; 9 10in { 11 12 options = { 13 14 services.domoticz = { 15 enable = mkEnableOption (lib.mdDoc pkgDesc); 16 17 bind = mkOption { 18 type = types.str; 19 default = "0.0.0.0"; 20 description = lib.mdDoc "IP address to bind to."; 21 }; 22 23 port = mkOption { 24 type = types.port; 25 default = 8080; 26 description = lib.mdDoc "Port to bind to for HTTP, set to 0 to disable HTTP."; 27 }; 28 29 }; 30 31 }; 32 33 config = mkIf cfg.enable { 34 35 systemd.services."domoticz" = { 36 description = pkgDesc; 37 wantedBy = [ "multi-user.target" ]; 38 after = [ "network-online.target" ]; 39 serviceConfig = { 40 DynamicUser = true; 41 StateDirectory = "domoticz"; 42 Restart = "always"; 43 ExecStart = '' 44 ${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 45 ''; 46 }; 47 }; 48 49 }; 50 51}