2021-06-04 09:07:49 +00:00
|
|
|
{ lib
|
|
|
|
, beamPackages
|
2023-10-09 19:29:22 +00:00
|
|
|
, buildNpmPackage
|
2021-06-04 09:07:49 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, nodejs
|
|
|
|
, nixosTests
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pname = "plausible";
|
2023-10-09 19:29:22 +00:00
|
|
|
version = "2.0.0";
|
2021-06-04 09:07:49 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "plausible";
|
|
|
|
repo = "analytics";
|
|
|
|
rev = "v${version}";
|
2023-10-09 19:29:22 +00:00
|
|
|
hash = "sha256-yrTwxBguAZbfEKucUL+w49Hr6D7v9/2OjY1h27+w5WI=";
|
2021-06-04 09:07:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# TODO consider using `mix2nix` as soon as it supports git dependencies.
|
|
|
|
mixFodDeps = beamPackages.fetchMixDeps {
|
|
|
|
pname = "${pname}-deps";
|
|
|
|
inherit src version;
|
2023-10-09 19:29:22 +00:00
|
|
|
hash = "sha256-CAyZLpjmw1JreK3MopqI0XsWhP+fJEMpXlww7CibSaM=";
|
2021-06-04 09:07:49 +00:00
|
|
|
};
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
assets = buildNpmPackage {
|
|
|
|
pname = "${pname}-assets";
|
2021-06-04 09:07:49 +00:00
|
|
|
inherit version;
|
2023-10-09 19:29:22 +00:00
|
|
|
src = "${src}/assets";
|
|
|
|
npmDepsHash = "sha256-2t1M6RQhBjZxx36qawVUVC+ob9SvQIq5dy4HgVeY2Eo=";
|
|
|
|
dontNpmBuild = true;
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
cp -r . "$out"
|
|
|
|
runHook postInstall
|
2021-06-04 09:07:49 +00:00
|
|
|
'';
|
2023-10-09 19:29:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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-04 09:07:49 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
beamPackages.mixRelease {
|
|
|
|
inherit pname version src mixFodDeps;
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
nodejs
|
|
|
|
];
|
2021-06-04 09:07:49 +00:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
tests = { inherit (nixosTests) plausible; };
|
|
|
|
updateScript = ./update.sh;
|
|
|
|
};
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace lib/plausible_release.ex --replace 'defp prepare do' 'def prepare do'
|
|
|
|
'';
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
rm -r assets tracker
|
|
|
|
cp -r ${assets} assets
|
|
|
|
cp -r ${tracker} tracker
|
|
|
|
'';
|
|
|
|
|
2021-06-04 09:07:49 +00:00
|
|
|
postBuild = ''
|
2022-09-30 11:47:45 +00:00
|
|
|
export NODE_OPTIONS=--openssl-legacy-provider # required for webpack compatibility with OpenSSL 3 (https://github.com/webpack/webpack/issues/14532)
|
2021-06-04 09:07:49 +00:00
|
|
|
npm run deploy --prefix ./assets
|
2023-10-09 19:29:22 +00:00
|
|
|
npm run deploy --prefix ./tracker
|
2021-06-04 09:07:49 +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
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
license = licenses.agpl3Plus;
|
|
|
|
homepage = "https://plausible.io/";
|
2023-10-09 19:29:22 +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";
|
|
|
|
maintainers = with maintainers; [ softinio ];
|
2021-06-04 09:07:49 +00:00
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|