Skip to content

Commit 1c698f5

Browse files
authored
matomo: refactor, matomo-beta: remove (NixOS#374022)
2 parents c068347 + 7c2e8f1 commit 1c698f5

File tree

10 files changed

+172
-210
lines changed

10 files changed

+172
-210
lines changed

nixos/doc/manual/release-notes/rl-2505.section.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@
291291

292292
- `matomo` now defaults to version 5 (previously available as `matomo_5`). Version 4 has been removed as it reached EOL on December 19, 2024.
293293

294+
- `matomo-beta` has been removed as the version of the `matomo` package can now be easily overriden through `overrideAttrs` (see [PR #374022](https://github.com/NixOS/nixpkgs/pull/374022))
295+
294296
- `docker_24` has been removed, as it was EOL with vulnerabilites since June 08, 2024.
295297

296298
- `containerd` has been updated to v2, which contains breaking changes. See the [containerd

nixos/tests/all-tests.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ in {
587587
mate = handleTest ./mate.nix {};
588588
mate-wayland = handleTest ./mate-wayland.nix {};
589589
matter-server = handleTest ./matter-server.nix {};
590-
matomo = handleTest ./matomo.nix {};
590+
matomo = runTest ./matomo.nix;
591591
matrix-appservice-irc = runTest ./matrix/appservice-irc.nix;
592592
matrix-conduit = handleTest ./matrix/conduit.nix {};
593593
matrix-synapse = handleTest ./matrix/synapse.nix {};

nixos/tests/matomo.nix

Lines changed: 45 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,58 @@
1+
{ lib, ... }:
12
{
2-
system ? builtins.currentSystem,
3-
config ? { },
4-
pkgs ? import ../.. { inherit system config; },
5-
}:
6-
7-
with import ../lib/testing-python.nix { inherit system pkgs; };
8-
with pkgs.lib;
9-
10-
let
11-
matomoTest =
12-
package:
13-
makeTest {
14-
name = "matomo";
15-
16-
nodes.machine =
17-
{ config, pkgs, ... }:
18-
{
19-
services.matomo = {
20-
package = package;
21-
enable = true;
22-
nginx = {
23-
forceSSL = false;
24-
enableACME = false;
25-
};
26-
};
27-
services.mysql = {
28-
enable = true;
29-
package = pkgs.mariadb;
30-
};
31-
services.nginx.enable = true;
3+
name = "matomo";
4+
5+
nodes.machine =
6+
{ config, pkgs, ... }:
7+
{
8+
services.matomo = {
9+
enable = true;
10+
nginx = {
11+
forceSSL = false;
12+
enableACME = false;
3213
};
14+
};
15+
services.mysql = {
16+
enable = true;
17+
package = pkgs.mariadb;
18+
};
19+
services.nginx.enable = true;
20+
};
3321

34-
testScript = ''
35-
start_all()
36-
machine.wait_for_unit("mysql.service")
37-
machine.wait_for_unit("phpfpm-matomo.service")
38-
machine.wait_for_unit("nginx.service")
22+
testScript = ''
23+
start_all()
24+
machine.wait_for_unit("mysql.service")
25+
machine.wait_for_unit("phpfpm-matomo.service")
26+
machine.wait_for_unit("nginx.service")
3927
40-
with subtest("matomo.js reachable via HTTP"):
41-
machine.succeed("curl -sSfk http://machine/matomo.js")
28+
with subtest("matomo.js reachable via HTTP"):
29+
machine.succeed("curl -sSfk http://machine/matomo.js")
4230
43-
with subtest("js/piwik.js reachable via HTTP"):
44-
machine.succeed("curl -sSfk http://machine/js/piwik.js")
31+
with subtest("js/piwik.js reachable via HTTP"):
32+
machine.succeed("curl -sSfk http://machine/js/piwik.js")
4533
46-
with subtest("matomo.php (API) reachable via HTTP"):
47-
machine.succeed("curl -sSfk http://machine/matomo.php")
34+
with subtest("matomo.php (API) reachable via HTTP"):
35+
machine.succeed("curl -sSfk http://machine/matomo.php")
4836
49-
# without the grep the command does not produce valid utf-8 for some reason
50-
with subtest("welcome screen loads"):
51-
machine.succeed(
52-
"curl -sSfL http://localhost/ | grep '<title>Matomo[^<]*Installation'"
53-
)
37+
# without the grep the command does not produce valid utf-8 for some reason
38+
with subtest("welcome screen loads"):
39+
machine.succeed(
40+
"curl -sSfL http://localhost/ | grep '<title>Matomo[^<]*Installation'"
41+
)
5442
55-
with subtest("killing the phpfpm process should trigger an automatic restart"):
56-
machine.succeed("systemctl kill -s KILL phpfpm-matomo")
57-
machine.sleep(1)
58-
machine.wait_for_unit("phpfpm-matomo.service")
59-
'';
60-
};
61-
in
62-
{
63-
matomo = matomoTest pkgs.matomo // {
64-
name = "matomo";
65-
meta.maintainers =
66-
with maintainers;
67-
[
68-
florianjacob
69-
mmilata
70-
twey
71-
boozedog
72-
]
73-
++ lib.teams.flyingcircus.members;
74-
};
75-
matomo-beta = matomoTest pkgs.matomo-beta // {
76-
name = "matomo-beta";
77-
meta.maintainers = with maintainers; [
43+
with subtest("killing the phpfpm process should trigger an automatic restart"):
44+
machine.succeed("systemctl kill -s KILL phpfpm-matomo")
45+
machine.sleep(1)
46+
machine.wait_for_unit("phpfpm-matomo.service")
47+
'';
48+
49+
meta.maintainers =
50+
with lib.maintainers;
51+
[
7852
florianjacob
7953
mmilata
8054
twey
8155
boozedog
82-
];
83-
};
56+
]
57+
++ lib.teams.flyingcircus.members;
8458
}
File renamed without changes.

pkgs/servers/web-apps/matomo/change-path-geoip2-5.x.patch renamed to pkgs/by-name/ma/matomo/change-path-geoip2-5.x.patch

File renamed without changes.

pkgs/servers/web-apps/matomo/make-localhost-default-database-host.patch renamed to pkgs/by-name/ma/matomo/make-localhost-default-database-host.patch

File renamed without changes.

pkgs/by-name/ma/matomo/package.nix

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
lib,
3+
stdenv,
4+
fetchurl,
5+
makeWrapper,
6+
php,
7+
nixosTests,
8+
nix-update-script,
9+
}:
10+
11+
stdenv.mkDerivation (finalAttrs: {
12+
pname = "matomo";
13+
version = "5.2.1";
14+
15+
src = fetchurl {
16+
url = "https://builds.matomo.org/matomo-${finalAttrs.version}.tar.gz";
17+
hash = "sha256-5glMwwIG0Uo8bu904u40FUa+yaUlrQe1nUCkv9/ATks=";
18+
};
19+
20+
nativeBuildInputs = [ makeWrapper ];
21+
22+
patches = [
23+
# This changes the default value of the database server field
24+
# from 127.0.0.1 to localhost.
25+
# unix socket authentication only works with localhost,
26+
# but password-based SQL authentication works with both.
27+
# TODO: is upstream interested in this?
28+
# -> discussion at https://github.com/matomo-org/matomo/issues/12646
29+
./make-localhost-default-database-host.patch
30+
# This changes the default config for path.geoip2 so that it doesn't point
31+
# to the nix store.
32+
./change-path-geoip2-5.x.patch
33+
];
34+
35+
# this bootstrap.php adds support for getting PIWIK_USER_PATH
36+
# from an environment variable. Point it to a mutable location
37+
# to be able to use matomo read-only from the nix store
38+
postPatch = ''
39+
cp ${./bootstrap.php} bootstrap.php
40+
'';
41+
42+
# TODO: future versions might rename the PIWIK_… variables to MATOMO_…
43+
# TODO: Move more unnecessary files from share/, especially using PIWIK_INCLUDE_PATH.
44+
# See https://forum.matomo.org/t/bootstrap-php/5926/10 and
45+
# https://github.com/matomo-org/matomo/issues/11654#issuecomment-297730843
46+
installPhase = ''
47+
runHook preInstall
48+
49+
# copy everything to share/, used as webroot folder, and then remove what's known to be not needed
50+
mkdir -p $out/share
51+
cp -ra * $out/share/
52+
# tmp/ is created by matomo in PIWIK_USER_PATH
53+
rmdir $out/share/tmp
54+
# config/ needs to be accessed by PIWIK_USER_PATH anyway
55+
ln -s $out/share/config $out/
56+
57+
makeWrapper ${php}/bin/php $out/bin/matomo-console \
58+
--add-flags "$out/share/console"
59+
60+
runHook postInstall
61+
'';
62+
63+
filesToFix = [
64+
"misc/composer/build-xhprof.sh"
65+
"misc/composer/clean-xhprof.sh"
66+
"misc/cron/archive.sh"
67+
"plugins/GeoIp2/config/config.php"
68+
"plugins/Installation/FormDatabaseSetup.php"
69+
"vendor/pear/archive_tar/sync-php4"
70+
"vendor/szymach/c-pchart/coverage.sh"
71+
"vendor/matomo/matomo-php-tracker/run_tests.sh"
72+
"vendor/twig/twig/drupal_test.sh"
73+
];
74+
75+
# This fixes the consistency check in the admin interface
76+
#
77+
# The filesToFix list may contain files that are exclusive to only one of the versions we build
78+
# make sure to test for existence to avoid erroring on an incompatible version and failing
79+
postFixup = ''
80+
pushd $out/share > /dev/null
81+
for f in $filesToFix; do
82+
if [ -f "$f" ]; then
83+
length="$(wc -c "$f" | cut -d' ' -f1)"
84+
hash="$(md5sum "$f" | cut -d' ' -f1)"
85+
sed -i "s:\\(\"$f\"[^(]*(\\).*:\\1\"$length\", \"$hash\"),:g" config/manifest.inc.php
86+
else
87+
echo "INFO(files-to-fix): $f does not exist in this version"
88+
fi
89+
done
90+
popd > /dev/null
91+
'';
92+
93+
passthru = {
94+
updateScript = nix-update-script {
95+
extraArgs = [
96+
"--url"
97+
"https://github.com/matomo-org/matomo"
98+
];
99+
};
100+
tests = lib.optionalAttrs stdenv.hostPlatform.isLinux {
101+
inherit (nixosTests) matomo;
102+
};
103+
};
104+
105+
meta = {
106+
description = "Real-time web analytics application";
107+
mainProgram = "matomo-console";
108+
license = lib.licenses.gpl3Plus;
109+
homepage = "https://matomo.org/";
110+
changelog = "https://github.com/matomo-org/matomo/releases/tag/${finalAttrs.version}";
111+
platforms = lib.platforms.all;
112+
maintainers =
113+
with lib.maintainers;
114+
[
115+
florianjacob
116+
sebbel
117+
twey
118+
boozedog
119+
niklaskorz
120+
]
121+
++ lib.teams.flyingcircus.members;
122+
};
123+
})

0 commit comments

Comments
 (0)