git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #69342 from Kiwi/matomo-updates

Matomo (module, package) updates

commit722b99beb99a7468d99fa42ce806a9a44d3b752f authorAaron Andersen <aaron@fosslib.net> dateTue 29 Oct 2019, 23:09 (7 years ago) parentf65db05605379b
7 files changed+96−42
nixos/modules/rename.nix+2−1 nixos/modules/services/web-apps/matomo-doc.xml+1−1 nixos/modules/services/web-apps/matomo.nix+22−34 nixos/tests/all-tests.nix+1 nixos/tests/matomo.nix+43 pkgs/servers/web-apps/matomo/default.nix+24−5 pkgs/top-level/all-packages.nix+3−1
nixos/modules/rename.nix+2−1
@@ -135,7 +135,8 @@ with lib;
135135 # piwik was renamed to matomo
136136 (mkRenamedOptionModule [ "services" "piwik" "enable" ] [ "services" "matomo" "enable" ])
137137 (mkRenamedOptionModule [ "services" "piwik" "webServerUser" ] [ "services" "matomo" "webServerUser" ])
138− (mkRenamedOptionModule [ "services" "piwik" "phpfpmProcessManagerConfig" ] [ "services" "matomo" "phpfpmProcessManagerConfig" ])
138+ (mkRemovedOptionModule [ "services" "piwik" "phpfpmProcessManagerConfig" ] "Use services.phpfpm.pools.<name>.settings")
139+ (mkRemovedOptionModule [ "services" "matomo" "phpfpmProcessManagerConfig" ] "Use services.phpfpm.pools.<name>.settings")
139140 (mkRenamedOptionModule [ "services" "piwik" "nginx" ] [ "services" "matomo" "nginx" ])
140141
141142 # tarsnap
nixos/modules/services/web-apps/matomo-doc.xml+1−1
@@ -105,7 +105,7 @@ GRANT ALL PRIVILEGES ON matomo.* TO 'matomo'@'localhost';
105105 <para>
106106 You can use other web servers by forwarding calls for
107107 <filename>index.php</filename> and <filename>piwik.php</filename> to the
108− <literal>/run/phpfpm-matomo.sock</literal> fastcgi unix socket. You can use
108+ <literal><link linkend="opt-services.phpfpm.pools._name_.socket">services.phpfpm.pools.&lt;name&gt;.socket</link></literal> fastcgi unix socket. You can use
109109 the nginx configuration in the module code as a reference to what else
110110 should be configured.
111111 </para>
nixos/modules/services/web-apps/matomo.nix+22−34
@@ -2,15 +2,13 @@
22with lib;
33let
44 cfg = config.services.matomo;
5+ fpm = config.services.phpfpm.pools.${pool};
56
67 user = "matomo";
78 dataDir = "/var/lib/${user}";
89 deprecatedDataDir = "/var/lib/piwik";
910
1011 pool = user;
11− # it's not possible to use /run/phpfpm/${pool}.sock because /run/phpfpm/ is root:root 0770,
12− # and therefore is not accessible by the web server.
13− phpSocket = "/run/phpfpm-${pool}.sock";
1412 phpExecutionUnit = "phpfpm-${pool}";
1513 databaseService = "mysql.service";
1614
@@ -50,7 +48,7 @@ in {
5048 default = null;
5149 example = "lighttpd";
5250 description = ''
53− Name of the web server user that forwards requests to the ${phpSocket} fastcgi socket for Matomo if the nginx
51+ Name of the web server user that forwards requests to <option>services.phpfpm.pools.&lt;name&gt;.socket</option> the fastcgi socket for Matomo if the nginx
5452 option is not used. Either this option or the nginx option is mandatory.
5553 If you want to use another webserver than nginx, you need to set this to that server's user
5654 and pass fastcgi requests to `index.php`, `matomo.php` and `piwik.php` (legacy name) to this socket.
@@ -71,25 +69,6 @@ in {
7169 '';
7270 };
7371
74− phpfpmProcessManagerConfig = mkOption {
75− type = types.str;
76− default = ''
77− ; default phpfpm process manager settings
78− pm = dynamic
79− pm.max_children = 75
80− pm.start_servers = 10
81− pm.min_spare_servers = 5
82− pm.max_spare_servers = 20
83− pm.max_requests = 500
84−
85− ; log worker's stdout, but this has a performance hit
86− catch_workers_output = yes
87− '';
88− description = ''
89− Settings for phpfpm's process manager. You might need to change this depending on the load for Matomo.
90− '';
91− };
92−
9372 nginx = mkOption {
9473 type = types.nullOr (types.submodule (
9574 recursiveUpdate
@@ -233,15 +212,24 @@ in {
233212 else if (cfg.webServerUser != null) then cfg.webServerUser else "";
234213 in {
235214 ${pool} = {
236− listen = phpSocket;
237− extraConfig = ''
238− listen.owner = ${socketOwner}
239− listen.group = root
240− listen.mode = 0600
241− user = ${user}
242− env[PIWIK_USER_PATH] = ${dataDir}
243− ${cfg.phpfpmProcessManagerConfig}
215+ inherit user;
216+ phpOptions = ''
217+ error_log = 'stderr'
218+ log_errors = on
244219 '';
220+ settings = mapAttrs (name: mkDefault) {
221+ "listen.owner" = socketOwner;
222+ "listen.group" = "root";
223+ "listen.mode" = "0660";
224+ "pm" = "dynamic";
225+ "pm.max_children" = 75;
226+ "pm.start_servers" = 10;
227+ "pm.min_spare_servers" = 5;
228+ "pm.max_spare_servers" = 20;
229+ "pm.max_requests" = 500;
230+ "catch_workers_output" = true;
231+ };
232+ phpEnv.PIWIK_USER_PATH = dataDir;
245233 };
246234 };
247235
@@ -264,15 +252,15 @@ in {
264252 };
265253 # allow index.php for webinterface
266254 locations."= /index.php".extraConfig = ''
267− fastcgi_pass unix:${phpSocket};
255+ fastcgi_pass unix:${fpm.socket};
268256 '';
269257 # allow matomo.php for tracking
270258 locations."= /matomo.php".extraConfig = ''
271− fastcgi_pass unix:${phpSocket};
259+ fastcgi_pass unix:${fpm.socket};
272260 '';
273261 # allow piwik.php for tracking (deprecated name)
274262 locations."= /piwik.php".extraConfig = ''
275− fastcgi_pass unix:${phpSocket};
263+ fastcgi_pass unix:${fpm.socket};
276264 '';
277265 # Any other attempt to access any php files is forbidden
278266 locations."~* ^.+\\.php$".extraConfig = ''
nixos/tests/all-tests.nix+1
@@ -159,6 +159,7 @@ in
159159 #logstash = handleTest ./logstash.nix {};
160160 mailcatcher = handleTest ./mailcatcher.nix {};
161161 mathics = handleTest ./mathics.nix {};
162+ matomo = handleTest ./matomo.nix {};
162163 matrix-synapse = handleTest ./matrix-synapse.nix {};
163164 mediawiki = handleTest ./mediawiki.nix {};
164165 memcached = handleTest ./memcached.nix {};
nixos/tests/matomo.nixnew file+43
@@ -0,0 +1,43 @@
1+{ system ? builtins.currentSystem, config ? { }
2+, pkgs ? import ../.. { inherit system config; } }:
3+
4+with import ../lib/testing.nix { inherit system pkgs; };
5+with pkgs.lib;
6+
7+let
8+ matomoTest = package:
9+ makeTest {
10+ machine = { config, pkgs, ... }: {
11+ services.matomo = {
12+ package = package;
13+ enable = true;
14+ nginx = {
15+ forceSSL = false;
16+ enableACME = false;
17+ };
18+ };
19+ services.mysql = {
20+ enable = true;
21+ package = pkgs.mysql;
22+ };
23+ services.nginx.enable = true;
24+ };
25+
26+ testScript = ''
27+ startAll;
28+ $machine->waitForUnit("mysql.service");
29+ $machine->waitForUnit("phpfpm-matomo.service");
30+ $machine->waitForUnit("nginx.service");
31+ $machine->succeed("curl -sSfL http://localhost/ | grep '<title>Matomo[^<]*Installation'");
32+ '';
33+ };
34+in {
35+ matomo = matomoTest pkgs.matomo // {
36+ name = "matomo";
37+ meta.maintainers = with maintainers; [ florianjacob kiwi mmilata ];
38+ };
39+ matomo-beta = matomoTest pkgs.matomo-beta // {
40+ name = "matomo-beta";
41+ meta.maintainers = with maintainers; [ florianjacob kiwi mmilata ];
42+ };
43+}
pkgs/servers/web-apps/matomo/default.nix+24−5
@@ -1,12 +1,30 @@
11{ stdenv, fetchurl, makeWrapper, php }:
22
3+let
4+ versions = {
5+ matomo = {
6+ version = "3.11.0";
7+ sha256 = "1fbnmmzzsi3dfm9qm30wypxjcazl37mryaik9mlrb19hnp2md40q";
8+ };
9+
10+ matomo-beta = {
11+ version = "3.12.0";
12+ beta = 3;
13+ sha256 = "1n7b8cag7rpi6y4145cll2irz3in4668jkiicy06wm5nq6lb4bdf";
14+ };
15+ };
16+ common = pname: {version, sha256, beta ? null}:
17+ let fullVersion = version + stdenv.lib.optionalString (beta != null) "-b${toString beta}";
18+ name = "${pname}-${fullVersion}";
19+in
20+
321stdenv.mkDerivation rec {
4− pname = "matomo";
5− version = "3.11.0";
22+ inherit name;
23+ version = fullVersion;
624
725 src = fetchurl {
826 url = "https://builds.matomo.org/matomo-${version}.tar.gz";
9− sha256 = "1fbnmmzzsi3dfm9qm30wypxjcazl37mryaik9mlrb19hnp2md40q";
27+ inherit sha256;
1028 };
1129
1230 nativeBuildInputs = [ makeWrapper ];
@@ -53,6 +71,7 @@ stdenv.mkDerivation rec {
5371 license = licenses.gpl3Plus;
5472 homepage = https://matomo.org/;
5573 platforms = platforms.all;
56− maintainers = [ maintainers.florianjacob ];
74+ maintainers = with maintainers; [ florianjacob kiwi ];
5775 };
58−}
76+};
77+in stdenv.lib.mapAttrs common versions
pkgs/top-level/all-packages.nix+3−1
@@ -15480,7 +15480,9 @@ in
1548015480
1548115481 shiori = callPackage ../servers/web-apps/shiori { };
1548215482
15483− matomo = callPackage ../servers/web-apps/matomo { };
15483+ inherit (callPackages ../servers/web-apps/matomo {})
15484+ matomo
15485+ matomo-beta;
1548415486
1548515487 axis2 = callPackage ../servers/http/tomcat/axis2 { };
1548615488