2021-06-04 09:07:49 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, beamPackages
|
|
|
|
, fetchFromGitHub
|
|
|
|
, glibcLocales
|
|
|
|
, cacert
|
|
|
|
, mkYarnModules
|
2021-12-06 16:07:01 +00:00
|
|
|
, fetchYarnDeps
|
2021-06-04 09:07:49 +00:00
|
|
|
, nodejs
|
|
|
|
, nixosTests
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pname = "plausible";
|
2021-12-06 16:07:01 +00:00
|
|
|
version = "1.4.0";
|
2021-06-04 09:07:49 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "plausible";
|
|
|
|
repo = "analytics";
|
|
|
|
rev = "v${version}";
|
2021-12-06 16:07:01 +00:00
|
|
|
sha256 = "1d31y7mwvml17w97dm5c4312n0ciq39kf4hz3g80hdzbbn72mi4q";
|
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;
|
2021-12-06 16:07:01 +00:00
|
|
|
sha256 = "1ikcskp4gvvdprl65x1spijdc8dz6klnrnkvgy2jbk0b3d7yn1v5";
|
2021-06-04 09:07:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
yarnDeps = mkYarnModules {
|
|
|
|
pname = "${pname}-yarn-deps";
|
|
|
|
inherit version;
|
|
|
|
packageJSON = ./package.json;
|
|
|
|
yarnLock = ./yarn.lock;
|
2021-12-06 16:07:01 +00:00
|
|
|
yarnNix = ./yarn.nix;
|
2021-06-04 09:07:49 +00:00
|
|
|
preBuild = ''
|
|
|
|
mkdir -p tmp/deps
|
|
|
|
cp -r ${mixFodDeps}/phoenix tmp/deps/phoenix
|
|
|
|
cp -r ${mixFodDeps}/phoenix_html tmp/deps/phoenix_html
|
|
|
|
'';
|
|
|
|
postBuild = ''
|
|
|
|
echo 'module.exports = {}' > $out/node_modules/flatpickr/dist/postcss.config.js
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
beamPackages.mixRelease {
|
|
|
|
inherit pname version src mixFodDeps;
|
|
|
|
|
|
|
|
nativeBuildInputs = [ nodejs ];
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
tests = { inherit (nixosTests) plausible; };
|
|
|
|
updateScript = ./update.sh;
|
|
|
|
};
|
|
|
|
|
|
|
|
postBuild = ''
|
|
|
|
ln -sf ${yarnDeps}/node_modules assets/node_modules
|
|
|
|
npm run deploy --prefix ./assets
|
|
|
|
|
|
|
|
# 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/";
|
|
|
|
description = " Simple, open-source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics.";
|
|
|
|
maintainers = with maintainers; [ ma27 ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|