diff --git a/nixos/tests/matomo.nix b/nixos/tests/matomo.nix index e944229dede86..7592f4e2f43a5 100644 --- a/nixos/tests/matomo.nix +++ b/nixos/tests/matomo.nix @@ -69,15 +69,6 @@ in boozedog ]; }; - matomo-beta = matomoTest pkgs.matomo-beta // { - name = "matomo-beta"; - meta.maintainers = with maintainers; [ - florianjacob - mmilata - twey - boozedog - ]; - }; matomo_5 = matomoTest pkgs.matomo_5 // { name = "matomo-5"; meta.maintainers = 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-4.x.patch b/pkgs/by-name/ma/matomo/change-path-geoip2-4.x.patch similarity index 100% rename from pkgs/servers/web-apps/matomo/change-path-geoip2-4.x.patch rename to pkgs/by-name/ma/matomo/change-path-geoip2-4.x.patch 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/by-name/ma/matomo/package.nix b/pkgs/by-name/ma/matomo/package.nix new file mode 100644 index 0000000000000..c6eb6a454872c --- /dev/null +++ b/pkgs/by-name/ma/matomo/package.nix @@ -0,0 +1,125 @@ +{ + lib, + stdenv, + fetchurl, + makeWrapper, + php, + nixosTests, +}: +let + fetchurl' = lib.makeOverridable fetchurl; +in +stdenv.mkDerivation (finalAttrs: { + name = "matomo"; + version = "5.2.2"; + + src = fetchurl' { + url = "https://builds.matomo.org/matomo-${finalAttrs.version}.tar.gz"; + hash = "sha256-ZEwz/KKZZwTFsKfwR0iKZM1ta4CUXJsWgBXika+pjb0="; + }; + + 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. + ( + if lib.versionOlder finalAttrs.version "5.0" then + ./change-path-geoip2-4.x.patch + else + ./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 = + if (lib.versionOlder finalAttrs.version "5.0") then + nixosTests.matomo.matomo + else + nixosTests.matomo.matomo_5; + }; + + meta = { + description = "Real-time web analytics application"; + mainProgram = "matomo-console"; + license = lib.licenses.gpl3Plus; + homepage = "https://matomo.org/"; + platforms = lib.platforms.all; + maintainers = + with lib.maintainers; + [ + florianjacob + sebbel + twey + boozedog + niklaskorz + ] + ++ lib.teams.flyingcircus.members; + knownVulnerabilities = lib.optional (lib.versionOlder finalAttrs.version "5.0") "Support for Matomo 4 ended on 2024-12-19. It is recommended to upgrade to `matomo_5` instead."; + }; +}) diff --git a/pkgs/servers/web-apps/matomo/default.nix b/pkgs/servers/web-apps/matomo/default.nix deleted file mode 100644 index d0c644dc8e0b5..0000000000000 --- a/pkgs/servers/web-apps/matomo/default.nix +++ /dev/null @@ -1,145 +0,0 @@ -{ - lib, - stdenv, - fetchurl, - makeWrapper, - php, - nixosTests, -}: - -let - versions = { - matomo = { - version = "4.16.1"; - hash = "sha256-cGnsxfpvt7FyhxFcA2/gWWe7CyanVGZVKtCDES3XLdI="; - }; - matomo_5 = { - version = "5.2.2"; - hash = "sha256-ZEwz/KKZZwTFsKfwR0iKZM1ta4CUXJsWgBXika+pjb0="; - }; - matomo-beta = { - version = "5.2.2"; - # `beta` examples: "b1", "rc1", null - # when updating: use null if stable version is >= latest beta or release candidate - beta = null; - hash = "sha256-ZEwz/KKZZwTFsKfwR0iKZM1ta4CUXJsWgBXika+pjb0="; - }; - }; - 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. - ( - if lib.versionOlder finalAttrs.version "5.0" then - ./change-path-geoip2-4.x.patch - else - ./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; - knownVulnerabilities = lib.optional (lib.versionOlder finalAttrs.version "5.0") "Support for Matomo 4 ended on 2024-12-19. It is recommended to upgrade to `matomo_5` instead."; - }; - }); -in -lib.mapAttrs common versions diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index ec2297bb4843f..4e8eb2d737a13 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -768,6 +768,7 @@ mapAliases { mathematica9 = throw "mathematica9 has been removed as it was obsolete, broken, and depended on OpenCV 2"; # Added 2024-08-20 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-beta = lib.warn "matomo-beta will be removed in NixOS 25.05" matomo_5; # Added 2025-02-03 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 195ad84ee6d96..6dcd1160f7e82 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12268,10 +12268,25 @@ with pkgs; }; tt-rss = callPackage ../servers/tt-rss { }; - inherit (callPackages ../servers/web-apps/matomo {}) - matomo + + inherit + ({ + # To allow automatic backports of Matomo 5 PRs, the path must match what we + # have on `master`. + # We still want to provide the contents of this package as `matomo_5` in 24.11 + # to not introduce a breaking change while preserving `matomo` as the EOL + # Matomo 4.x. + matomo_5 = callPackage ../by-name/ma/matomo/package.nix { }; + # Matomo 4 reached EOL and will be replaced by matomo_5 in NixOS 25.05 + matomo = matomo_5.overrideAttrs (old: { + version = "4.16.1"; + src = old.src.override { + hash = "sha256-cGnsxfpvt7FyhxFcA2/gWWe7CyanVGZVKtCDES3XLdI="; + }; + }); + }) matomo_5 - matomo-beta; + matomo; inherit (callPackages ../servers/unifi { }) unifi8;