2021-06-01 18:59:59 +03:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, beamPackages
|
|
|
|
, fetchFromGitHub
|
|
|
|
, glibcLocales
|
|
|
|
, cacert
|
|
|
|
, mkYarnModules
|
|
|
|
, nodejs
|
|
|
|
, fetchpatch
|
|
|
|
, nixosTests
|
2021-05-22 00:15:23 +03:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pname = "plausible";
|
|
|
|
version = "1.3.0";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "plausible";
|
|
|
|
repo = "analytics";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "03lm1f29gwwixnhgjish5bhi3m73qyp71ns2sczdnwnbhrw61zps";
|
|
|
|
};
|
|
|
|
|
2021-05-29 17:13:20 +03:00
|
|
|
# TODO consider using `mix2nix` as soon as it supports git dependencies.
|
|
|
|
mixFodDeps = beamPackages.fetchMixDeps {
|
2021-05-22 00:15:23 +03:00
|
|
|
pname = "${pname}-deps";
|
|
|
|
inherit src version;
|
2021-07-14 06:29:51 +03:00
|
|
|
sha256 = "1x0if0ifk272vcqjlgf097pxsw13bhwy8vs0b89l0bssx1bzygsi";
|
2021-06-02 12:48:02 +03:00
|
|
|
|
|
|
|
# We need ecto 3.6 as this version checks whether the database exists before
|
|
|
|
# trying to create it. The creation attempt would always require super-user privileges
|
|
|
|
# and since 3.6 this isn't the case anymore.
|
2021-07-14 06:29:51 +03:00
|
|
|
patches = [
|
|
|
|
./ecto_sql-fix.patch
|
|
|
|
./plausible-Bump-clickhouse_ecto-dependency-to-be-compatible-with-ecto-3.6.patch
|
|
|
|
];
|
2021-05-22 00:15:23 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
yarnDeps = mkYarnModules {
|
|
|
|
pname = "${pname}-yarn-deps";
|
|
|
|
inherit version;
|
|
|
|
packageJSON = ./package.json;
|
|
|
|
yarnNix = ./yarn.nix;
|
|
|
|
yarnLock = ./yarn.lock;
|
|
|
|
preBuild = ''
|
|
|
|
mkdir -p tmp/deps
|
2021-05-29 17:13:20 +03:00
|
|
|
cp -r ${mixFodDeps}/phoenix tmp/deps/phoenix
|
|
|
|
cp -r ${mixFodDeps}/phoenix_html tmp/deps/phoenix_html
|
2021-05-22 00:15:23 +03:00
|
|
|
'';
|
|
|
|
postBuild = ''
|
|
|
|
echo 'module.exports = {}' > $out/node_modules/flatpickr/dist/postcss.config.js
|
|
|
|
'';
|
|
|
|
};
|
2021-06-01 18:59:59 +03:00
|
|
|
in
|
|
|
|
beamPackages.mixRelease {
|
2021-05-29 17:13:20 +03:00
|
|
|
inherit pname version src mixFodDeps;
|
2021-05-22 00:15:23 +03:00
|
|
|
|
|
|
|
nativeBuildInputs = [ nodejs ];
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# Allow socket-authentication against postgresql. Upstream PR is
|
|
|
|
# https://github.com/plausible/analytics/pull/1052
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/Ma27/analytics/commit/f2ee5892a6c3e1a861d69ed30cac43e05e9cd36f.patch";
|
|
|
|
sha256 = "sha256-JvJ7xlGw+tHtWje+jiQChVC4KTyqqdq2q+MIcOv/k1o=";
|
|
|
|
})
|
2021-05-29 17:13:20 +03:00
|
|
|
|
2021-06-01 18:59:59 +03:00
|
|
|
# Ensure that `tzdata` doesn't write into its store-path
|
|
|
|
# https://github.com/plausible/analytics/pull/1096, but rebased onto 1.3.0
|
|
|
|
./tzdata-rebased.patch
|
2021-05-22 00:15:23 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
tests = { inherit (nixosTests) plausible; };
|
|
|
|
updateScript = ./update.sh;
|
|
|
|
};
|
|
|
|
|
2021-06-01 18:59:59 +03:00
|
|
|
postBuild = ''
|
2021-05-22 00:15:23 +03:00
|
|
|
ln -sf ${yarnDeps}/node_modules assets/node_modules
|
|
|
|
npm run deploy --prefix ./assets
|
2021-05-31 20:01:39 +03: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-22 00:15:23 +03:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
license = licenses.agpl3Plus;
|
|
|
|
homepage = "https://plausible.io/";
|
|
|
|
description = " Simple, open-source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics.";
|
|
|
|
maintainers = with maintainers; [ ma27 ];
|
2021-05-31 20:03:12 +03:00
|
|
|
platforms = platforms.unix;
|
2021-05-22 00:15:23 +03:00
|
|
|
};
|
|
|
|
}
|