2021-06-01 16:59:59 +01:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, beamPackages
|
|
|
|
, fetchFromGitHub
|
|
|
|
, glibcLocales
|
|
|
|
, cacert
|
|
|
|
, mkYarnModules
|
2021-10-28 10:44:02 +01:00
|
|
|
, fetchYarnDeps
|
2021-06-01 16:59:59 +01:00
|
|
|
, nodejs
|
|
|
|
, nixosTests
|
2021-05-21 22:15:23 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pname = "plausible";
|
2022-01-30 04:10:45 +00:00
|
|
|
version = "1.4.4";
|
2021-05-21 22:15:23 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "plausible";
|
|
|
|
repo = "analytics";
|
|
|
|
rev = "v${version}";
|
2022-01-30 04:10:45 +00:00
|
|
|
sha256 = "1ckw5cd4z96jkjhmzjq7k3kzjj7bvj38i5xq9r43cz0sn7w3470k";
|
2021-05-21 22:15:23 +01:00
|
|
|
};
|
|
|
|
|
2021-05-29 15:13:20 +01:00
|
|
|
# TODO consider using `mix2nix` as soon as it supports git dependencies.
|
|
|
|
mixFodDeps = beamPackages.fetchMixDeps {
|
2021-05-21 22:15:23 +01:00
|
|
|
pname = "${pname}-deps";
|
|
|
|
inherit src version;
|
2021-11-06 13:10:16 +00:00
|
|
|
sha256 = "1ikcskp4gvvdprl65x1spijdc8dz6klnrnkvgy2jbk0b3d7yn1v5";
|
2021-05-21 22:15:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
yarnDeps = mkYarnModules {
|
|
|
|
pname = "${pname}-yarn-deps";
|
|
|
|
inherit version;
|
|
|
|
packageJSON = ./package.json;
|
|
|
|
yarnLock = ./yarn.lock;
|
2021-10-28 10:44:02 +01:00
|
|
|
yarnNix = ./yarn.nix;
|
2021-05-21 22:15:23 +01:00
|
|
|
preBuild = ''
|
|
|
|
mkdir -p tmp/deps
|
2021-05-29 15:13:20 +01:00
|
|
|
cp -r ${mixFodDeps}/phoenix tmp/deps/phoenix
|
|
|
|
cp -r ${mixFodDeps}/phoenix_html tmp/deps/phoenix_html
|
2021-05-21 22:15:23 +01:00
|
|
|
'';
|
|
|
|
postBuild = ''
|
|
|
|
echo 'module.exports = {}' > $out/node_modules/flatpickr/dist/postcss.config.js
|
|
|
|
'';
|
|
|
|
};
|
2021-06-01 16:59:59 +01:00
|
|
|
in
|
|
|
|
beamPackages.mixRelease {
|
2021-05-29 15:13:20 +01:00
|
|
|
inherit pname version src mixFodDeps;
|
2021-05-21 22:15:23 +01:00
|
|
|
|
|
|
|
nativeBuildInputs = [ nodejs ];
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
tests = { inherit (nixosTests) plausible; };
|
|
|
|
updateScript = ./update.sh;
|
|
|
|
};
|
|
|
|
|
2021-06-01 16:59:59 +01:00
|
|
|
postBuild = ''
|
2021-05-21 22:15:23 +01:00
|
|
|
ln -sf ${yarnDeps}/node_modules assets/node_modules
|
|
|
|
npm run deploy --prefix ./assets
|
2021-05-31 18:01:39 +01: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 22:15:23 +01: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 18:03:12 +01:00
|
|
|
platforms = platforms.unix;
|
2021-05-21 22:15:23 +01:00
|
|
|
};
|
|
|
|
}
|