2023-08-20 21:03:22 +02:00
|
|
|
{ lib, stdenv, fetchurl, makeWrapper, php, nixosTests }:
|
2017-04-23 15:51:21 +02:00
|
|
|
|
2019-09-24 10:08:19 +02:00
|
|
|
let
|
|
|
|
versions = {
|
|
|
|
matomo = {
|
2023-12-15 22:59:16 +01:00
|
|
|
version = "4.16.0";
|
|
|
|
hash = "sha256-OFZT4195WTWw2XNAyGiNixW6hSNKC3IyBpa5kM9PCVk=";
|
2019-09-24 10:08:19 +02:00
|
|
|
};
|
|
|
|
matomo-beta = {
|
2023-08-20 21:04:08 +02:00
|
|
|
version = "5.0.0";
|
2020-02-11 15:32:29 +01:00
|
|
|
# `beta` examples: "b1", "rc1", null
|
2021-10-25 02:42:03 +02:00
|
|
|
# when updating: use null if stable version is >= latest beta or release candidate
|
2023-12-15 23:02:17 +01:00
|
|
|
beta = "rc9";
|
|
|
|
hash = "sha256-OXxJCEXcrl6UXYh+jbNqLQGYphrSjxaOAZg3AZVPAqs=";
|
2019-09-24 10:08:19 +02:00
|
|
|
};
|
|
|
|
};
|
2023-06-10 14:46:41 +02:00
|
|
|
common = pname: { version, hash, beta ? null }:
|
2020-02-11 15:32:29 +01:00
|
|
|
let
|
2021-01-15 08:07:56 +01:00
|
|
|
fullVersion = version + lib.optionalString (beta != null) "-${toString beta}";
|
2020-02-11 15:32:29 +01:00
|
|
|
name = "${pname}-${fullVersion}";
|
|
|
|
in
|
2019-09-24 10:08:19 +02:00
|
|
|
|
2020-02-11 15:32:29 +01:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
inherit name;
|
|
|
|
version = fullVersion;
|
2017-04-23 15:51:21 +02:00
|
|
|
|
2020-02-11 15:32:29 +01:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://builds.matomo.org/matomo-${version}.tar.gz";
|
2023-06-10 14:46:41 +02:00
|
|
|
inherit hash;
|
2020-02-11 15:32:29 +01:00
|
|
|
};
|
2017-04-23 15:51:21 +02:00
|
|
|
|
2020-02-11 15:32:29 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2017-04-23 15:51:21 +02:00
|
|
|
|
2020-10-14 23:25:54 +02:00
|
|
|
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.
|
2023-08-20 21:04:08 +02:00
|
|
|
(if lib.versionOlder version "5.0"
|
|
|
|
then ./change-path-geoip2-4.x.patch
|
|
|
|
else ./change-path-geoip2-5.x.patch)
|
2020-10-14 23:25:54 +02:00
|
|
|
];
|
2018-01-16 17:24:49 +01:00
|
|
|
|
2020-02-11 15:32:29 +01:00
|
|
|
# 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
|
|
|
|
'';
|
2017-04-23 15:51:21 +02:00
|
|
|
|
2020-02-11 15:32:29 +01:00
|
|
|
# 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
|
2017-04-23 15:51:21 +02:00
|
|
|
|
2020-02-11 15:32:29 +01:00
|
|
|
# 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/
|
2017-04-23 15:51:21 +02:00
|
|
|
|
2020-02-11 15:32:29 +01:00
|
|
|
makeWrapper ${php}/bin/php $out/bin/matomo-console \
|
|
|
|
--add-flags "$out/share/console"
|
2017-04-23 15:51:21 +02:00
|
|
|
|
2020-02-11 15:32:29 +01:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2017-04-23 15:51:21 +02:00
|
|
|
|
2020-02-11 15:32:29 +01:00
|
|
|
filesToFix = [
|
|
|
|
"misc/composer/build-xhprof.sh"
|
|
|
|
"misc/composer/clean-xhprof.sh"
|
|
|
|
"misc/cron/archive.sh"
|
2020-10-14 23:25:54 +02:00
|
|
|
"plugins/GeoIp2/config/config.php"
|
2020-02-11 15:32:29 +01:00
|
|
|
"plugins/Installation/FormDatabaseSetup.php"
|
|
|
|
"vendor/pear/archive_tar/sync-php4"
|
|
|
|
"vendor/szymach/c-pchart/coverage.sh"
|
2021-10-25 02:17:02 +02:00
|
|
|
"vendor/matomo/matomo-php-tracker/run_tests.sh"
|
2020-02-11 15:32:29 +01:00
|
|
|
"vendor/twig/twig/drupal_test.sh"
|
|
|
|
];
|
2019-11-17 19:44:59 +01:00
|
|
|
|
2020-02-11 15:32:29 +01:00
|
|
|
# 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
|
2021-10-25 02:17:02 +02:00
|
|
|
else
|
|
|
|
echo "INFO(files-to-fix): $f does not exist in this version"
|
2020-02-11 15:32:29 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
popd > /dev/null
|
|
|
|
'';
|
2019-11-17 19:44:59 +01:00
|
|
|
|
2023-08-20 21:03:22 +02:00
|
|
|
passthru = {
|
|
|
|
tests = nixosTests.matomo."${pname}";
|
|
|
|
};
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2020-02-11 15:32:29 +01:00
|
|
|
description = "A real-time web analytics application";
|
|
|
|
license = licenses.gpl3Plus;
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "https://matomo.org/";
|
2020-02-11 15:32:29 +01:00
|
|
|
platforms = platforms.all;
|
2023-08-20 21:02:32 +02:00
|
|
|
maintainers = with maintainers; [ florianjacob kiwi sebbel twey boozedog ] ++ teams.flyingcircus.members;
|
2020-02-11 15:32:29 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
2021-01-15 08:07:56 +01:00
|
|
|
lib.mapAttrs common versions
|