nixpkgs/pkgs/servers/web-apps/plausible/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

77 lines
2.1 KiB
Nix
Raw Normal View History

2021-06-01 15:59:59 +00:00
{ lib
, stdenv
, beamPackages
, fetchFromGitHub
, glibcLocales
, cacert
, mkYarnModules
2021-10-28 09:44:02 +00:00
, fetchYarnDeps
2021-06-01 15:59:59 +00:00
, nodejs
, nixosTests
2021-05-21 21:15:23 +00:00
}:
let
pname = "plausible";
version = "1.4.4";
2021-05-21 21:15:23 +00:00
src = fetchFromGitHub {
owner = "plausible";
repo = "analytics";
rev = "v${version}";
hash = "sha256-Exwy+LEafDZITriXiIbc60j555gHy1+hnNKkTxorfLI=";
2021-05-21 21:15:23 +00:00
};
# TODO consider using `mix2nix` as soon as it supports git dependencies.
mixFodDeps = beamPackages.fetchMixDeps {
2021-05-21 21:15:23 +00:00
pname = "${pname}-deps";
inherit src version;
2023-06-04 22:28:35 +00:00
hash = "sha256-ZQfrTxsLzCWFf3vabOk0vyHWZLw69GJovm3vR+7UbMY=";
2021-05-21 21:15:23 +00:00
};
yarnDeps = mkYarnModules {
pname = "${pname}-yarn-deps";
inherit version;
packageJSON = ./package.json;
yarnLock = ./yarn.lock;
2021-10-28 09:44:02 +00:00
yarnNix = ./yarn.nix;
2021-05-21 21:15:23 +00:00
preBuild = ''
mkdir -p tmp/deps
cp -r ${mixFodDeps}/phoenix tmp/deps/phoenix
cp -r ${mixFodDeps}/phoenix_html tmp/deps/phoenix_html
2021-05-21 21:15:23 +00:00
'';
postBuild = ''
echo 'module.exports = {}' > $out/node_modules/flatpickr/dist/postcss.config.js
'';
};
2021-06-01 15:59:59 +00:00
in
beamPackages.mixRelease {
inherit pname version src mixFodDeps;
2021-05-21 21:15:23 +00:00
nativeBuildInputs = [ nodejs ];
passthru = {
tests = { inherit (nixosTests) plausible; };
updateScript = ./update.sh;
};
2021-06-01 15:59:59 +00:00
postBuild = ''
export HOME=$TMPDIR
2022-09-28 01:12:22 +00:00
export NODE_OPTIONS=--openssl-legacy-provider # required for webpack compatibility with OpenSSL 3 (https://github.com/webpack/webpack/issues/14532)
2021-05-21 21:15:23 +00:00
ln -sf ${yarnDeps}/node_modules assets/node_modules
2023-05-14 07:18:34 +00:00
substituteInPlace assets/package.json --replace '$(npm bin)/' 'npx '
2021-05-21 21:15:23 +00:00
npm run deploy --prefix ./assets
2021-05-31 17:01:39 +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
2021-05-21 21:15:23 +00: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; [ ];
platforms = platforms.unix;
2021-05-21 21:15:23 +00:00
};
}