From d7ac52bd816b0f28a1070c4c90c2e24061ab34a0 Mon Sep 17 00:00:00 2001 From: Niklas Korz Date: Wed, 15 Jan 2025 11:40:14 +0100 Subject: [PATCH 1/6] matomo-beta: remove --- nixos/doc/manual/release-notes/rl-2505.section.md | 2 ++ nixos/tests/matomo.nix | 9 --------- pkgs/servers/web-apps/matomo/default.nix | 7 ------- pkgs/top-level/aliases.nix | 1 + pkgs/top-level/all-packages.nix | 3 +-- 5 files changed, 4 insertions(+), 18 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2505.section.md b/nixos/doc/manual/release-notes/rl-2505.section.md index fd625646c11e..d21764cbb4ce 100644 --- a/nixos/doc/manual/release-notes/rl-2505.section.md +++ b/nixos/doc/manual/release-notes/rl-2505.section.md @@ -263,6 +263,8 @@ - `matomo` now defaults to version 5 (previously available as `matomo_5`). Version 4 has been removed as it reached EOL on December 19, 2024. +- `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)) + - `docker_24` has been removed, as it was EOL with vulnerabilites since June 08, 2024. - `containerd` has been updated to v2, which contains breaking changes. See the [containerd diff --git a/nixos/tests/matomo.nix b/nixos/tests/matomo.nix index 1a40fa93a557..ef1aeeee75c2 100644 --- a/nixos/tests/matomo.nix +++ b/nixos/tests/matomo.nix @@ -72,13 +72,4 @@ in ] ++ lib.teams.flyingcircus.members; }; - matomo-beta = matomoTest pkgs.matomo-beta // { - name = "matomo-beta"; - meta.maintainers = with maintainers; [ - florianjacob - mmilata - twey - boozedog - ]; - }; } diff --git a/pkgs/servers/web-apps/matomo/default.nix b/pkgs/servers/web-apps/matomo/default.nix index eab263044cec..58869c75bb90 100644 --- a/pkgs/servers/web-apps/matomo/default.nix +++ b/pkgs/servers/web-apps/matomo/default.nix @@ -13,13 +13,6 @@ let version = "5.2.1"; hash = "sha256-5glMwwIG0Uo8bu904u40FUa+yaUlrQe1nUCkv9/ATks="; }; - matomo-beta = { - version = "5.2.1"; - # `beta` examples: "b1", "rc1", null - # when updating: use null if stable version is >= latest beta or release candidate - beta = null; - hash = "sha256-5glMwwIG0Uo8bu904u40FUa+yaUlrQe1nUCkv9/ATks="; - }; }; common = pname: diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index fa8a07f695dd..36f89f55d86d 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -837,6 +837,7 @@ mapAliases { mathematica10 = throw "mathematica10 has been removed as it was obsolete, broken, and depended on OpenCV 2"; # Added 2024-08-20 mathematica11 = throw "mathematica11 has been removed as it was obsolete, broken, and depended on OpenCV 2"; # Added 2024-08-20 matomo_5 = matomo; # Added 2024-12-12 + matomo-beta = throw "matomo-beta has been removed as it mostly just pointed to the latest matomo release, use `matomo.overrideAttrs` to access a specific beta version instead"; # Added 2025-01-15 matrique = throw "'matrique' has been renamed to/replaced by 'spectral'"; # Converted to throw 2024-10-17 matrix-sliding-sync = throw "matrix-sliding-sync has been removed as matrix-synapse 114.0 and later covers its functionality"; # Added 2024-10-20 maui-nota = libsForQt5.mauiPackages.nota; # added 2022-05-17 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d749d9178c49..2fb9e4464d06 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11883,8 +11883,7 @@ with pkgs; tt-rss = callPackage ../servers/tt-rss { }; inherit (callPackages ../servers/web-apps/matomo {}) - matomo - matomo-beta; + matomo; unpackerr = callPackage ../servers/unpackerr { inherit (darwin.apple_sdk.frameworks) Cocoa WebKit; From 83eb8d8020d148cd151bbd5f93cd776ffef7dc7b Mon Sep 17 00:00:00 2001 From: Niklas Korz Date: Wed, 15 Jan 2025 11:47:35 +0100 Subject: [PATCH 2/6] matomo: refactor into single package file --- nixos/tests/matomo.nix | 116 ++++++------ pkgs/servers/web-apps/matomo/default.nix | 218 +++++++++++------------ pkgs/top-level/all-packages.nix | 3 +- 3 files changed, 156 insertions(+), 181 deletions(-) diff --git a/nixos/tests/matomo.nix b/nixos/tests/matomo.nix index ef1aeeee75c2..a3351b573265 100644 --- a/nixos/tests/matomo.nix +++ b/nixos/tests/matomo.nix @@ -5,71 +5,61 @@ }: with import ../lib/testing-python.nix { inherit system pkgs; }; -with pkgs.lib; -let - matomoTest = - package: - makeTest { - name = "matomo"; +makeTest { + name = "matomo"; - nodes.machine = - { config, pkgs, ... }: - { - services.matomo = { - package = package; - enable = true; - nginx = { - forceSSL = false; - enableACME = false; - }; - }; - services.mysql = { - enable = true; - package = pkgs.mariadb; - }; - services.nginx.enable = true; + nodes.machine = + { config, pkgs, ... }: + { + services.matomo = { + enable = true; + nginx = { + forceSSL = false; + enableACME = false; }; - - testScript = '' - start_all() - machine.wait_for_unit("mysql.service") - machine.wait_for_unit("phpfpm-matomo.service") - machine.wait_for_unit("nginx.service") - - with subtest("matomo.js reachable via HTTP"): - machine.succeed("curl -sSfk http://machine/matomo.js") - - with subtest("js/piwik.js reachable via HTTP"): - machine.succeed("curl -sSfk http://machine/js/piwik.js") - - with subtest("matomo.php (API) reachable via HTTP"): - machine.succeed("curl -sSfk http://machine/matomo.php") - - # without the grep the command does not produce valid utf-8 for some reason - with subtest("welcome screen loads"): - machine.succeed( - "curl -sSfL http://localhost/ | grep 'Matomo[^<]*Installation'" - ) - - with subtest("killing the phpfpm process should trigger an automatic restart"): - machine.succeed("systemctl kill -s KILL phpfpm-matomo") - machine.sleep(1) - machine.wait_for_unit("phpfpm-matomo.service") - ''; + }; + services.mysql = { + enable = true; + package = pkgs.mariadb; + }; + services.nginx.enable = true; }; -in -{ - matomo = matomoTest pkgs.matomo // { - name = "matomo"; - meta.maintainers = - with maintainers; - [ - florianjacob - mmilata - twey - boozedog - ] - ++ lib.teams.flyingcircus.members; - }; + + testScript = '' + start_all() + machine.wait_for_unit("mysql.service") + machine.wait_for_unit("phpfpm-matomo.service") + machine.wait_for_unit("nginx.service") + + with subtest("matomo.js reachable via HTTP"): + machine.succeed("curl -sSfk http://machine/matomo.js") + + with subtest("js/piwik.js reachable via HTTP"): + machine.succeed("curl -sSfk http://machine/js/piwik.js") + + with subtest("matomo.php (API) reachable via HTTP"): + machine.succeed("curl -sSfk http://machine/matomo.php") + + # without the grep the command does not produce valid utf-8 for some reason + with subtest("welcome screen loads"): + machine.succeed( + "curl -sSfL http://localhost/ | grep '<title>Matomo[^<]*Installation'" + ) + + with subtest("killing the phpfpm process should trigger an automatic restart"): + machine.succeed("systemctl kill -s KILL phpfpm-matomo") + machine.sleep(1) + machine.wait_for_unit("phpfpm-matomo.service") + ''; + + meta.maintainers = + with pkgs.lib.maintainers; + [ + florianjacob + mmilata + twey + boozedog + ] + ++ pkgs.lib.teams.flyingcircus.members; } diff --git a/pkgs/servers/web-apps/matomo/default.nix b/pkgs/servers/web-apps/matomo/default.nix index 58869c75bb90..b63ed013ad5d 100644 --- a/pkgs/servers/web-apps/matomo/default.nix +++ b/pkgs/servers/web-apps/matomo/default.nix @@ -7,122 +7,108 @@ nixosTests, }: -let - versions = { - matomo = { - version = "5.2.1"; - hash = "sha256-5glMwwIG0Uo8bu904u40FUa+yaUlrQe1nUCkv9/ATks="; +stdenv.mkDerivation (finalAttrs: { + pname = "matomo"; + version = "5.2.1"; + + src = fetchurl { + url = "https://builds.matomo.org/matomo-${finalAttrs.version}.tar.gz"; + hash = "sha256-5glMwwIG0Uo8bu904u40FUa+yaUlrQe1nUCkv9/ATks="; + }; + + nativeBuildInputs = [ makeWrapper ]; + + patches = [ + # This changes the default value of the database server field + # from 127.0.0.1 to localhost. + # unix socket authentication only works with localhost, + # but password-based SQL authentication works with both. + # TODO: is upstream interested in this? + # -> discussion at https://github.com/matomo-org/matomo/issues/12646 + ./make-localhost-default-database-host.patch + # This changes the default config for path.geoip2 so that it doesn't point + # to the nix store. + ./change-path-geoip2-5.x.patch + ]; + + # this bootstrap.php adds support for getting PIWIK_USER_PATH + # from an environment variable. Point it to a mutable location + # to be able to use matomo read-only from the nix store + postPatch = '' + cp ${./bootstrap.php} bootstrap.php + ''; + + # TODO: future versions might rename the PIWIK_… variables to MATOMO_… + # TODO: Move more unnecessary files from share/, especially using PIWIK_INCLUDE_PATH. + # See https://forum.matomo.org/t/bootstrap-php/5926/10 and + # https://github.com/matomo-org/matomo/issues/11654#issuecomment-297730843 + installPhase = '' + runHook preInstall + + # copy everything to share/, used as webroot folder, and then remove what's known to be not needed + mkdir -p $out/share + cp -ra * $out/share/ + # tmp/ is created by matomo in PIWIK_USER_PATH + rmdir $out/share/tmp + # config/ needs to be accessed by PIWIK_USER_PATH anyway + ln -s $out/share/config $out/ + + makeWrapper ${php}/bin/php $out/bin/matomo-console \ + --add-flags "$out/share/console" + + runHook postInstall + ''; + + filesToFix = [ + "misc/composer/build-xhprof.sh" + "misc/composer/clean-xhprof.sh" + "misc/cron/archive.sh" + "plugins/GeoIp2/config/config.php" + "plugins/Installation/FormDatabaseSetup.php" + "vendor/pear/archive_tar/sync-php4" + "vendor/szymach/c-pchart/coverage.sh" + "vendor/matomo/matomo-php-tracker/run_tests.sh" + "vendor/twig/twig/drupal_test.sh" + ]; + + # This fixes the consistency check in the admin interface + # + # The filesToFix list may contain files that are exclusive to only one of the versions we build + # make sure to test for existence to avoid erroring on an incompatible version and failing + postFixup = '' + pushd $out/share > /dev/null + for f in $filesToFix; do + if [ -f "$f" ]; then + length="$(wc -c "$f" | cut -d' ' -f1)" + hash="$(md5sum "$f" | cut -d' ' -f1)" + sed -i "s:\\(\"$f\"[^(]*(\\).*:\\1\"$length\", \"$hash\"),:g" config/manifest.inc.php + else + echo "INFO(files-to-fix): $f does not exist in this version" + fi + done + popd > /dev/null + ''; + + passthru = { + tests = lib.optionalAttrs stdenv.hostPlatform.isLinux { + inherit (nixosTests) matomo; }; }; - common = - pname: - { - version, - hash, - beta ? null, - }: - stdenv.mkDerivation (finalAttrs: { - name = "${pname}-${finalAttrs.version}"; - version = version + lib.optionalString (beta != null) "-${toString beta}"; - src = fetchurl { - url = "https://builds.matomo.org/matomo-${finalAttrs.version}.tar.gz"; - inherit hash; - }; - - nativeBuildInputs = [ makeWrapper ]; - - patches = [ - # This changes the default value of the database server field - # from 127.0.0.1 to localhost. - # unix socket authentication only works with localhost, - # but password-based SQL authentication works with both. - # TODO: is upstream interested in this? - # -> discussion at https://github.com/matomo-org/matomo/issues/12646 - ./make-localhost-default-database-host.patch - # This changes the default config for path.geoip2 so that it doesn't point - # to the nix store. - ./change-path-geoip2-5.x.patch - ]; - - # this bootstrap.php adds support for getting PIWIK_USER_PATH - # from an environment variable. Point it to a mutable location - # to be able to use matomo read-only from the nix store - postPatch = '' - cp ${./bootstrap.php} bootstrap.php - ''; - - # TODO: future versions might rename the PIWIK_… variables to MATOMO_… - # TODO: Move more unnecessary files from share/, especially using PIWIK_INCLUDE_PATH. - # See https://forum.matomo.org/t/bootstrap-php/5926/10 and - # https://github.com/matomo-org/matomo/issues/11654#issuecomment-297730843 - installPhase = '' - runHook preInstall - - # copy everything to share/, used as webroot folder, and then remove what's known to be not needed - mkdir -p $out/share - cp -ra * $out/share/ - # tmp/ is created by matomo in PIWIK_USER_PATH - rmdir $out/share/tmp - # config/ needs to be accessed by PIWIK_USER_PATH anyway - ln -s $out/share/config $out/ - - makeWrapper ${php}/bin/php $out/bin/matomo-console \ - --add-flags "$out/share/console" - - runHook postInstall - ''; - - filesToFix = [ - "misc/composer/build-xhprof.sh" - "misc/composer/clean-xhprof.sh" - "misc/cron/archive.sh" - "plugins/GeoIp2/config/config.php" - "plugins/Installation/FormDatabaseSetup.php" - "vendor/pear/archive_tar/sync-php4" - "vendor/szymach/c-pchart/coverage.sh" - "vendor/matomo/matomo-php-tracker/run_tests.sh" - "vendor/twig/twig/drupal_test.sh" - ]; - - # This fixes the consistency check in the admin interface - # - # The filesToFix list may contain files that are exclusive to only one of the versions we build - # make sure to test for existence to avoid erroring on an incompatible version and failing - postFixup = '' - pushd $out/share > /dev/null - for f in $filesToFix; do - if [ -f "$f" ]; then - length="$(wc -c "$f" | cut -d' ' -f1)" - hash="$(md5sum "$f" | cut -d' ' -f1)" - sed -i "s:\\(\"$f\"[^(]*(\\).*:\\1\"$length\", \"$hash\"),:g" config/manifest.inc.php - else - echo "INFO(files-to-fix): $f does not exist in this version" - fi - done - popd > /dev/null - ''; - - passthru = { - tests = nixosTests.matomo."${pname}"; - }; - - meta = with lib; { - description = "Real-time web analytics application"; - mainProgram = "matomo-console"; - license = licenses.gpl3Plus; - homepage = "https://matomo.org/"; - platforms = platforms.all; - maintainers = - with maintainers; - [ - florianjacob - sebbel - twey - boozedog - ] - ++ teams.flyingcircus.members; - }; - }); -in -lib.mapAttrs common versions + meta = with lib; { + description = "Real-time web analytics application"; + mainProgram = "matomo-console"; + license = licenses.gpl3Plus; + homepage = "https://matomo.org/"; + platforms = platforms.all; + maintainers = + with maintainers; + [ + florianjacob + sebbel + twey + boozedog + ] + ++ teams.flyingcircus.members; + }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2fb9e4464d06..b36768390ec6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11882,8 +11882,7 @@ with pkgs; }; tt-rss = callPackage ../servers/tt-rss { }; - inherit (callPackages ../servers/web-apps/matomo {}) - matomo; + matomo = callPackage ../servers/web-apps/matomo { }; unpackerr = callPackage ../servers/unpackerr { inherit (darwin.apple_sdk.frameworks) Cocoa WebKit; From 252c0538e5dfcb84e687719293e7c1b9a17b5d9d Mon Sep 17 00:00:00 2001 From: Niklas Korz <niklas@niklaskorz.de> Date: Wed, 15 Jan 2025 11:56:10 +0100 Subject: [PATCH 3/6] matomo: move to pkgs/by-name --- pkgs/{servers/web-apps => by-name/ma}/matomo/bootstrap.php | 0 .../web-apps => by-name/ma}/matomo/change-path-geoip2-5.x.patch | 0 .../ma}/matomo/make-localhost-default-database-host.patch | 0 .../matomo/default.nix => by-name/ma/matomo/package.nix} | 0 pkgs/top-level/all-packages.nix | 1 - 5 files changed, 1 deletion(-) rename pkgs/{servers/web-apps => by-name/ma}/matomo/bootstrap.php (100%) rename pkgs/{servers/web-apps => by-name/ma}/matomo/change-path-geoip2-5.x.patch (100%) rename pkgs/{servers/web-apps => by-name/ma}/matomo/make-localhost-default-database-host.patch (100%) rename pkgs/{servers/web-apps/matomo/default.nix => by-name/ma/matomo/package.nix} (100%) diff --git a/pkgs/servers/web-apps/matomo/bootstrap.php b/pkgs/by-name/ma/matomo/bootstrap.php similarity index 100% rename from pkgs/servers/web-apps/matomo/bootstrap.php rename to pkgs/by-name/ma/matomo/bootstrap.php diff --git a/pkgs/servers/web-apps/matomo/change-path-geoip2-5.x.patch b/pkgs/by-name/ma/matomo/change-path-geoip2-5.x.patch similarity index 100% rename from pkgs/servers/web-apps/matomo/change-path-geoip2-5.x.patch rename to pkgs/by-name/ma/matomo/change-path-geoip2-5.x.patch diff --git a/pkgs/servers/web-apps/matomo/make-localhost-default-database-host.patch b/pkgs/by-name/ma/matomo/make-localhost-default-database-host.patch similarity index 100% rename from pkgs/servers/web-apps/matomo/make-localhost-default-database-host.patch rename to pkgs/by-name/ma/matomo/make-localhost-default-database-host.patch diff --git a/pkgs/servers/web-apps/matomo/default.nix b/pkgs/by-name/ma/matomo/package.nix similarity index 100% rename from pkgs/servers/web-apps/matomo/default.nix rename to pkgs/by-name/ma/matomo/package.nix diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b36768390ec6..5b8c12475582 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11882,7 +11882,6 @@ with pkgs; }; tt-rss = callPackage ../servers/tt-rss { }; - matomo = callPackage ../servers/web-apps/matomo { }; unpackerr = callPackage ../servers/unpackerr { inherit (darwin.apple_sdk.frameworks) Cocoa WebKit; From 1cc9c542bc08bf7e1f0eb057e81067125a150f56 Mon Sep 17 00:00:00 2001 From: Niklas Korz <niklas@niklaskorz.de> Date: Wed, 15 Jan 2025 11:57:24 +0100 Subject: [PATCH 4/6] matomo: add updateScript --- pkgs/by-name/ma/matomo/package.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/by-name/ma/matomo/package.nix b/pkgs/by-name/ma/matomo/package.nix index b63ed013ad5d..395a4272da59 100644 --- a/pkgs/by-name/ma/matomo/package.nix +++ b/pkgs/by-name/ma/matomo/package.nix @@ -5,6 +5,7 @@ makeWrapper, php, nixosTests, + nix-update-script, }: stdenv.mkDerivation (finalAttrs: { @@ -90,6 +91,12 @@ stdenv.mkDerivation (finalAttrs: { ''; passthru = { + updateScript = nix-update-script { + extraArgs = [ + "--url" + "https://github.com/matomo-org/matomo" + ]; + }; tests = lib.optionalAttrs stdenv.hostPlatform.isLinux { inherit (nixosTests) matomo; }; @@ -100,6 +107,7 @@ stdenv.mkDerivation (finalAttrs: { mainProgram = "matomo-console"; license = licenses.gpl3Plus; homepage = "https://matomo.org/"; + changelog = "https://github.com/matomo-org/matomo/releases/tag/${finalAttrs.version}"; platforms = platforms.all; maintainers = with maintainers; From e9750c60f30419dae1bc9af0d2b6a2ad2e45e1c7 Mon Sep 17 00:00:00 2001 From: Niklas Korz <niklas@niklaskorz.de> Date: Wed, 15 Jan 2025 12:05:22 +0100 Subject: [PATCH 5/6] matomo: add maintainer niklaskorz --- pkgs/by-name/ma/matomo/package.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/ma/matomo/package.nix b/pkgs/by-name/ma/matomo/package.nix index 395a4272da59..7954fe5009f2 100644 --- a/pkgs/by-name/ma/matomo/package.nix +++ b/pkgs/by-name/ma/matomo/package.nix @@ -102,21 +102,22 @@ stdenv.mkDerivation (finalAttrs: { }; }; - meta = with lib; { + meta = { description = "Real-time web analytics application"; mainProgram = "matomo-console"; - license = licenses.gpl3Plus; + license = lib.licenses.gpl3Plus; homepage = "https://matomo.org/"; changelog = "https://github.com/matomo-org/matomo/releases/tag/${finalAttrs.version}"; - platforms = platforms.all; + platforms = lib.platforms.all; maintainers = - with maintainers; + with lib.maintainers; [ florianjacob sebbel twey boozedog + niklaskorz ] - ++ teams.flyingcircus.members; + ++ lib.teams.flyingcircus.members; }; }) From 7c2e8f1b55016a0a7145e46127db986737693ad5 Mon Sep 17 00:00:00 2001 From: Niklas Korz <niklas@niklaskorz.de> Date: Wed, 15 Jan 2025 12:42:39 +0100 Subject: [PATCH 6/6] nixos/matomo: migrate tests from handleTest to runTest --- nixos/tests/all-tests.nix | 2 +- nixos/tests/matomo.nix | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 837bdc7e9fdd..acef9bb13f66 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -585,7 +585,7 @@ in { mate = handleTest ./mate.nix {}; mate-wayland = handleTest ./mate-wayland.nix {}; matter-server = handleTest ./matter-server.nix {}; - matomo = handleTest ./matomo.nix {}; + matomo = runTest ./matomo.nix; matrix-appservice-irc = runTest ./matrix/appservice-irc.nix; matrix-conduit = handleTest ./matrix/conduit.nix {}; matrix-synapse = handleTest ./matrix/synapse.nix {}; diff --git a/nixos/tests/matomo.nix b/nixos/tests/matomo.nix index a3351b573265..9562cb7e4e2b 100644 --- a/nixos/tests/matomo.nix +++ b/nixos/tests/matomo.nix @@ -1,12 +1,5 @@ +{ lib, ... }: { - system ? builtins.currentSystem, - config ? { }, - pkgs ? import ../.. { inherit system config; }, -}: - -with import ../lib/testing-python.nix { inherit system pkgs; }; - -makeTest { name = "matomo"; nodes.machine = @@ -54,12 +47,12 @@ makeTest { ''; meta.maintainers = - with pkgs.lib.maintainers; + with lib.maintainers; [ florianjacob mmilata twey boozedog ] - ++ pkgs.lib.teams.flyingcircus.members; + ++ lib.teams.flyingcircus.members; }