plausible: also install tracker

This commit is contained in:
Robert Schütz 2023-09-19 18:42:16 -07:00
parent f7f848d8cb
commit c4574a95c5
2 changed files with 36 additions and 11 deletions

View file

@ -30,6 +30,8 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
machine.succeed("curl -f localhost:8000 >&2") machine.succeed("curl -f localhost:8000 >&2")
machine.succeed("curl -f localhost:8000/js/script.js >&2")
csrf_token = machine.succeed( csrf_token = machine.succeed(
"curl -c /tmp/cookies localhost:8000/login | grep '_csrf_token' | sed -E 's,.*value=\"(.*)\".*,\\1,g'" "curl -c /tmp/cookies localhost:8000/login | grep '_csrf_token' | sed -E 's,.*value=\"(.*)\".*,\\1,g'"
) )

View file

@ -1,9 +1,8 @@
{ lib { lib
, beamPackages , beamPackages
, buildNpmPackage
, fetchFromGitHub , fetchFromGitHub
, nodejs , nodejs
, npmHooks
, fetchNpmDeps
, nixosTests , nixosTests
}: }:
@ -24,22 +23,40 @@ let
inherit src version; inherit src version;
hash = "sha256-CAyZLpjmw1JreK3MopqI0XsWhP+fJEMpXlww7CibSaM="; hash = "sha256-CAyZLpjmw1JreK3MopqI0XsWhP+fJEMpXlww7CibSaM=";
}; };
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
'';
};
in in
beamPackages.mixRelease { beamPackages.mixRelease {
inherit pname version src mixFodDeps; inherit pname version src mixFodDeps;
nativeBuildInputs = [ nativeBuildInputs = [
nodejs nodejs
npmHooks.npmConfigHook
]; ];
npmDeps = fetchNpmDeps {
src = "${src}/assets";
hash = "sha256-2t1M6RQhBjZxx36qawVUVC+ob9SvQIq5dy4HgVeY2Eo=";
};
npmRoot = "assets";
passthru = { passthru = {
tests = { inherit (nixosTests) plausible; }; tests = { inherit (nixosTests) plausible; };
updateScript = ./update.sh; updateScript = ./update.sh;
@ -49,10 +66,16 @@ beamPackages.mixRelease {
substituteInPlace lib/plausible_release.ex --replace 'defp prepare do' 'def prepare do' 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
'';
postBuild = '' postBuild = ''
export HOME=$TMPDIR
export NODE_OPTIONS=--openssl-legacy-provider # required for webpack compatibility with OpenSSL 3 (https://github.com/webpack/webpack/issues/14532) export NODE_OPTIONS=--openssl-legacy-provider # required for webpack compatibility with OpenSSL 3 (https://github.com/webpack/webpack/issues/14532)
npm run deploy --prefix ./assets npm run deploy --prefix ./assets
npm run deploy --prefix ./tracker
# for external task you need a workaround for the no deps check flag # for external task you need a workaround for the no deps check flag
# https://github.com/phoenixframework/phoenix/issues/2690 # https://github.com/phoenixframework/phoenix/issues/2690