From a5d98b2125dc99898f2d2616a87110760b8e1c71 Mon Sep 17 00:00:00 2001 From: Ed Cragg Date: Wed, 29 Apr 2020 23:25:25 +0100 Subject: [PATCH 1/5] maintainers: add edcragg --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 1877720d034e..5d6675906ba6 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -2176,6 +2176,12 @@ githubId = 984691; name = "Evan Danaher"; }; + edcragg = { + email = "ed.cragg@eipi.xyz"; + github = "nuxeh"; + githubId = 1516017; + name = "Ed Cragg"; + }; edef = { email = "edef@edef.eu"; github = "edef1c"; From 68f7d0748388406c5b52eda35d8320e0e23d7689 Mon Sep 17 00:00:00 2001 From: Ed Cragg Date: Thu, 30 Apr 2020 12:49:28 +0100 Subject: [PATCH 2/5] domoticz: init at 2020.2 --- pkgs/servers/domoticz/default.nix | 103 ++++++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 105 insertions(+) create mode 100644 pkgs/servers/domoticz/default.nix diff --git a/pkgs/servers/domoticz/default.nix b/pkgs/servers/domoticz/default.nix new file mode 100644 index 000000000000..f7b0548972af --- /dev/null +++ b/pkgs/servers/domoticz/default.nix @@ -0,0 +1,103 @@ +{ stdenv, + fetchzip, + makeWrapper, + cmake, + python3, + openssl, + pkg-config, + mosquitto, + lua5_3, + sqlite, + jsoncpp, + zlib, + boost, + curl, + git, + libusb-compat-0_1, + cereal +}: + +let + version = "2020.2"; + minizip = "f5282643091dc1b33546bb8d8b3c23d78fdba231"; + + domoticz-src = fetchzip { + url = "https://github.com/domoticz/domoticz/archive/${version}.tar.gz"; + sha256 = "1b4pkw9qp7f5r995vm4xdnpbwi9vxjyzbnk63bmy1xkvbhshm0g3"; + }; + + minizip-src = fetchzip { + url = "https://github.com/domoticz/minizip/archive/${minizip}.tar.gz"; + sha256 = "1vddrzm4pwl14bms91fs3mbqqjhcxrmpx9a68b6nfbs20xmpnsny"; + }; +in +stdenv.mkDerivation rec { + name = "domoticz"; + inherit version; + + src = domoticz-src; + + postUnpack = '' + cp -r ${minizip-src}/* $sourceRoot/extern/minizip + ''; + + enableParallelBuilding = true; + + buildInputs = [ + openssl + python3 + mosquitto + lua5_3 + sqlite + jsoncpp + boost + zlib + curl + git + libusb-compat-0_1 + cereal + ]; + + nativeBuildInputs = [ + cmake + pkg-config + makeWrapper + ]; + + cmakeFlags = [ + "-DCMAKE_BUILD_TYPE=Release" + "-DUSE_BUILTIN_MQTT=false" + "-DUSE_BUILTIN_LUA=false" + "-DUSE_BUILTIN_SQLITE=false" + "-DUSE_BUILTIN_JSONCPP=false" + "-DUSE_BUILTIN_ZLIB=false" + "-DUSE_OPENSSL_STATIC=false" + "-DUSE_STATIC_BOOST=false" + "-DUSE_BUILTIN_MINIZIP=true" + ]; + + installPhase = '' + mkdir -p $out/share/domoticz + cp -r $src/www $out/share/domoticz/ + cp -r $src/Config $out/share/domoticz + cp -r $src/scripts $out/share/domoticz + cp -r $src/plugins $out/share/domoticz + + mkdir -p $out/bin + cp domoticz $out/bin + wrapProgram $out/bin/domoticz --set LD_LIBRARY_PATH ${python3}/lib; + ''; + + meta = with stdenv.lib; { + description = "Home automation system"; + longDescription = '' + Domoticz is a home automation system that lets you monitor and configure + various devices like: lights, switches, various sensors/meters like + temperature, rain, wind, UV, electra, gas, water and much more + ''; + maintainers = with maintainers; [ edcragg ]; + homepage = "https://www.domoticz.com/"; + license = licenses.gpl3; + platforms = platforms.all; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 729f97d65a1e..e6a6f33ce894 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2976,6 +2976,8 @@ in inherit (darwin.apple_sdk.frameworks) CoreBluetooth ForceFeedback IOKit OpenGL; }; + domoticz = callPackage ../servers/domoticz { }; + doomseeker = qt5.callPackage ../applications/misc/doomseeker { }; doom-bcc = callPackage ../games/zdoom/bcc-git.nix { }; From c7683646526e3b5630b27c5e157bdca088500262 Mon Sep 17 00:00:00 2001 From: Ed Cragg Date: Thu, 30 Apr 2020 12:51:49 +0100 Subject: [PATCH 3/5] domoticz: add module --- nixos/modules/module-list.nix | 1 + nixos/modules/services/misc/domoticz.nix | 89 ++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 nixos/modules/services/misc/domoticz.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 89677970dd9a..9b707b978ded 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -432,6 +432,7 @@ ./services/misc/dysnomia.nix ./services/misc/disnix.nix ./services/misc/docker-registry.nix + ./services/misc/domoticz.nix ./services/misc/errbot.nix ./services/misc/etcd.nix ./services/misc/ethminer.nix diff --git a/nixos/modules/services/misc/domoticz.nix b/nixos/modules/services/misc/domoticz.nix new file mode 100644 index 000000000000..42b4218aa094 --- /dev/null +++ b/nixos/modules/services/misc/domoticz.nix @@ -0,0 +1,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 + ''; + }; + }; + + }; + +} From 4a3fe8d306bffc348c3a61ca2c9247dace1fc819 Mon Sep 17 00:00:00 2001 From: Ryan Mulligan Date: Sat, 10 Oct 2020 08:03:11 -0700 Subject: [PATCH 4/5] nixos/domoticz: use DynamicUser and StateDirectory --- nixos/modules/services/misc/domoticz.nix | 44 ++---------------------- 1 file changed, 3 insertions(+), 41 deletions(-) diff --git a/nixos/modules/services/misc/domoticz.nix b/nixos/modules/services/misc/domoticz.nix index 42b4218aa094..b1353d484048 100644 --- a/nixos/modules/services/misc/domoticz.nix +++ b/nixos/modules/services/misc/domoticz.nix @@ -14,31 +14,6 @@ in { 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"; @@ -57,29 +32,16 @@ in { 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; + DynamicUser = true; + StateDirectory = "domoticz"; 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 + ${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 ''; }; }; From 89e5a7f31f3b6f8be4041e5431c3fc3b6a085132 Mon Sep 17 00:00:00 2001 From: Ed Cragg Date: Sun, 11 Oct 2020 11:11:50 +0100 Subject: [PATCH 5/5] nixos/domoticz: update to use GPL3 plus license Per review comments on #86404 and [1]. [1] https://discourse.nixos.org/t/lib-licenses-gpl3-co-are-now-deprecated/8206 --- pkgs/servers/domoticz/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/servers/domoticz/default.nix b/pkgs/servers/domoticz/default.nix index f7b0548972af..8b1d11ab36b3 100644 --- a/pkgs/servers/domoticz/default.nix +++ b/pkgs/servers/domoticz/default.nix @@ -97,7 +97,7 @@ stdenv.mkDerivation rec { ''; maintainers = with maintainers; [ edcragg ]; homepage = "https://www.domoticz.com/"; - license = licenses.gpl3; + license = licenses.gpl3Plus; platforms = platforms.all; }; }