diff --git a/nixos/modules/services/web-apps/matomo.nix b/nixos/modules/services/web-apps/matomo.nix index b0d281cfb6ed..eba55e7e9bef 100644 --- a/nixos/modules/services/web-apps/matomo.nix +++ b/nixos/modules/services/web-apps/matomo.nix @@ -24,6 +24,7 @@ in { (mkRemovedOptionModule [ "services" "piwik" "phpfpmProcessManagerConfig" ] "Use services.phpfpm.pools..settings") (mkRemovedOptionModule [ "services" "matomo" "phpfpmProcessManagerConfig" ] "Use services.phpfpm.pools..settings") (mkRenamedOptionModule [ "services" "piwik" "nginx" ] [ "services" "matomo" "nginx" ]) + (mkRenamedOptionModule [ "services" "matomo" "periodicArchiveProcessingUrl" ] [ "services" "matomo" "hostname" ]) ]; options = { @@ -77,7 +78,7 @@ in { ''; }; - periodicArchiveProcessingUrl = mkOption { + hostname = mkOption { type = types.str; default = "${user}.${fqdn}"; example = "matomo.yourdomain.org"; @@ -170,6 +171,19 @@ in { fi chown -R ${user}:${user} ${dataDir} chmod -R ug+rwX,o-rwx ${dataDir} + + if [ -e ${dataDir}/current-package ]; then + CURRENT_PACKAGE=$(readlink ${dataDir}/current-package) + NEW_PACKAGE=${cfg.package} + if [ "$CURRENT_PACKAGE" != "$NEW_PACKAGE" ]; then + # keeping tmp arround between upgrades seems to bork stuff, so delete it + rm -rf ${dataDir}/tmp + fi + elif [ -e ${dataDir}/tmp ]; then + # upgrade from 4.4.1 + rm -rf ${dataDir}/tmp + fi + ln -sfT ${cfg.package} ${dataDir}/current-package ''; script = '' # Use User-Private Group scheme to protect Matomo data, but allow administration / backup via 'matomo' group @@ -202,7 +216,7 @@ in { UMask = "0007"; CPUSchedulingPolicy = "idle"; IOSchedulingClass = "idle"; - ExecStart = "${cfg.package}/bin/matomo-console core:archive --url=https://${cfg.periodicArchiveProcessingUrl}"; + ExecStart = "${cfg.package}/bin/matomo-console core:archive --url=https://${cfg.hostname}"; }; }; @@ -258,7 +272,7 @@ in { # References: # https://fralef.me/piwik-hardening-with-nginx-and-php-fpm.html # https://github.com/perusio/piwik-nginx - "${user}.${fqdn}" = mkMerge [ cfg.nginx { + "${cfg.hostname}" = mkMerge [ cfg.nginx { # don't allow to override the root easily, as it will almost certainly break Matomo. # disadvantage: not shown as default in docs. root = mkForce "${cfg.package}/share"; diff --git a/pkgs/servers/web-apps/matomo/default.nix b/pkgs/servers/web-apps/matomo/default.nix index 673b5bbc3b2d..ad8dc85f70fa 100644 --- a/pkgs/servers/web-apps/matomo/default.nix +++ b/pkgs/servers/web-apps/matomo/default.nix @@ -3,16 +3,16 @@ let versions = { matomo = { - version = "4.4.1"; - sha256 = "0y8ljdj97znvd3hkkr7s6s9k8m93agw3z9cfw1azzaxgc46akfcl"; + version = "4.5.0"; + sha256 = "sha256-OyjdzY+ENYxOTVjDLjj2unJbpaGODIH2I5Acmt45HDA="; }; matomo-beta = { - version = "4.4.1"; + version = "4.6.0"; # `beta` examples: "b1", "rc1", null - # TOOD when updating: use null if stable version is >= latest beta or release candidate - beta = null; - sha256 = "0y8ljdj97znvd3hkkr7s6s9k8m93agw3z9cfw1azzaxgc46akfcl"; + # when updating: use null if stable version is >= latest beta or release candidate + beta = "b2"; + sha256 = "sha256-7p/ZPtr5a/tBjrM27ILF3rNfxDIWuzWKCXNom3HlyL8="; }; }; common = pname: { version, sha256, beta ? null }: @@ -74,10 +74,9 @@ let "misc/composer/clean-xhprof.sh" "misc/cron/archive.sh" "plugins/Installation/FormDatabaseSetup.php" - "vendor/leafo/lessphp/package.sh" "vendor/pear/archive_tar/sync-php4" "vendor/szymach/c-pchart/coverage.sh" - # drupal_test.sh does not exist in 3.12.0-b3; added for 3.13.0 + "vendor/matomo/matomo-php-tracker/run_tests.sh" "vendor/twig/twig/drupal_test.sh" ]; @@ -92,6 +91,8 @@ let 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