2021-06-01 15:59:59 +00:00
|
|
|
{ lib
|
|
|
|
, beamPackages
|
2023-09-20 01:42:16 +00:00
|
|
|
, buildNpmPackage
|
2021-06-01 15:59:59 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, nodejs
|
|
|
|
, nixosTests
|
2023-10-29 21:03:06 +00:00
|
|
|
, ...
|
2021-05-21 21:15:23 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pname = "plausible";
|
2023-09-06 19:00:20 +00:00
|
|
|
version = "2.0.0";
|
2021-05-21 21:15:23 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "plausible";
|
|
|
|
repo = "analytics";
|
|
|
|
rev = "v${version}";
|
2023-09-06 19:00:20 +00:00
|
|
|
hash = "sha256-yrTwxBguAZbfEKucUL+w49Hr6D7v9/2OjY1h27+w5WI=";
|
2021-05-21 21:15:23 +00:00
|
|
|
};
|
|
|
|
|
2021-05-29 14:13:20 +00:00
|
|
|
# TODO consider using `mix2nix` as soon as it supports git dependencies.
|
|
|
|
mixFodDeps = beamPackages.fetchMixDeps {
|
2021-05-21 21:15:23 +00:00
|
|
|
pname = "${pname}-deps";
|
|
|
|
inherit src version;
|
2023-09-06 19:00:20 +00:00
|
|
|
hash = "sha256-CAyZLpjmw1JreK3MopqI0XsWhP+fJEMpXlww7CibSaM=";
|
2021-05-21 21:15:23 +00:00
|
|
|
};
|
2023-09-20 01:42:16 +00:00
|
|
|
|
|
|
|
assets = buildNpmPackage {
|
|
|
|
pname = "${pname}-assets";
|
|
|
|
inherit version;
|
|
|
|
src = "${src}/assets";
|
|
|
|
npmDepsHash = "sha256-2t1M6RQhBjZxx36qawVUVC+ob9SvQIq5dy4HgVeY2Eo=";
|
|
|
|
dontNpmBuild = true;
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
cp -r . "$out"
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tracker = buildNpmPackage {
|
|
|
|
pname = "${pname}-tracker";
|
|
|
|
inherit version;
|
|
|
|
src = "${src}/tracker";
|
|
|
|
npmDepsHash = "sha256-y09jVSwUrxF0nLpLqS1yQweYL+iMF6jVx0sUdQtvrpc=";
|
|
|
|
dontNpmBuild = true;
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
cp -r . "$out"
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
};
|
2021-06-01 15:59:59 +00:00
|
|
|
in
|
|
|
|
beamPackages.mixRelease {
|
2021-05-29 14:13:20 +00:00
|
|
|
inherit pname version src mixFodDeps;
|
2021-05-21 21:15:23 +00:00
|
|
|
|
2023-09-06 19:00:20 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
nodejs
|
|
|
|
];
|
|
|
|
|
2021-05-21 21:15:23 +00:00
|
|
|
passthru = {
|
|
|
|
tests = { inherit (nixosTests) plausible; };
|
|
|
|
updateScript = ./update.sh;
|
|
|
|
};
|
|
|
|
|
2023-04-30 22:31:55 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace lib/plausible_release.ex --replace 'defp prepare do' 'def prepare do'
|
|
|
|
'';
|
|
|
|
|
2023-09-20 01:42:16 +00:00
|
|
|
preBuild = ''
|
|
|
|
rm -r assets tracker
|
|
|
|
cp -r ${assets} assets
|
|
|
|
cp -r ${tracker} tracker
|
|
|
|
'';
|
|
|
|
|
2021-06-01 15:59:59 +00:00
|
|
|
postBuild = ''
|
2022-09-28 01:12:22 +00:00
|
|
|
export NODE_OPTIONS=--openssl-legacy-provider # required for webpack compatibility with OpenSSL 3 (https://github.com/webpack/webpack/issues/14532)
|
2021-05-21 21:15:23 +00:00
|
|
|
npm run deploy --prefix ./assets
|
2023-09-20 01:42:16 +00:00
|
|
|
npm run deploy --prefix ./tracker
|
2021-05-31 17:01:39 +00:00
|
|
|
|
|
|
|
# for external task you need a workaround for the no deps check flag
|
|
|
|
# https://github.com/phoenixframework/phoenix/issues/2690
|
|
|
|
mix do deps.loadpaths --no-deps-check, phx.digest
|
2021-05-21 21:15:23 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
license = licenses.agpl3Plus;
|
|
|
|
homepage = "https://plausible.io/";
|
2023-09-06 19:00:20 +00:00
|
|
|
changelog = "https://github.com/plausible/analytics/blob/${src.rev}/CHANGELOG.md";
|
|
|
|
description = " Simple, open-source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics";
|
2024-03-19 02:14:51 +00:00
|
|
|
mainProgram = "plausible";
|
2024-07-30 10:38:59 +00:00
|
|
|
maintainers = teams.cyberus.members;
|
2021-05-31 17:03:12 +00:00
|
|
|
platforms = platforms.unix;
|
2021-05-21 21:15:23 +00:00
|
|
|
};
|
|
|
|
}
|