diff --git a/nixos/modules/services/web-apps/plausible.nix b/nixos/modules/services/web-apps/plausible.nix index 7a6756d6fb2..caf5ba466df 100644 --- a/nixos/modules/services/web-apps/plausible.nix +++ b/nixos/modules/services/web-apps/plausible.nix @@ -190,7 +190,7 @@ in { environment = { # NixOS specific option to avoid that it's trying to write into its store-path. # See also https://github.com/lau/tzdata#data-directory-and-releases - PLAUSIBLE_TZDATA = "/var/lib/plausible/elixir_tzdata"; + TZDATA_DIR = "/var/lib/plausible/elixir_tzdata"; # Configuration options from # https://plausible.io/docs/self-hosting-configuration diff --git a/nixos/tests/plausible.nix b/nixos/tests/plausible.nix index eb14bf5f491..45e11f0270e 100644 --- a/nixos/tests/plausible.nix +++ b/nixos/tests/plausible.nix @@ -1,6 +1,6 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: { name = "plausible"; - meta = with pkgs.stdenv.lib.maintainers; { + meta = with lib.maintainers; { maintainers = [ ma27 ]; }; diff --git a/pkgs/servers/web-apps/plausible/default.nix b/pkgs/servers/web-apps/plausible/default.nix index 1fb37dc7ee0..c1cafb49d6a 100644 --- a/pkgs/servers/web-apps/plausible/default.nix +++ b/pkgs/servers/web-apps/plausible/default.nix @@ -1,5 +1,13 @@ -{ lib, stdenv, beamPackages, fetchFromGitHub, glibcLocales, cacert -, mkYarnModules, nodejs, fetchpatch, nixosTests +{ lib +, stdenv +, beamPackages +, fetchFromGitHub +, glibcLocales +, cacert +, mkYarnModules +, nodejs +, fetchpatch +, nixosTests }: let @@ -37,7 +45,8 @@ let echo 'module.exports = {}' > $out/node_modules/flatpickr/dist/postcss.config.js ''; }; -in beamPackages.mixRelease { +in +beamPackages.mixRelease { inherit pname version src mixFodDeps; nativeBuildInputs = [ nodejs ]; @@ -50,6 +59,10 @@ in beamPackages.mixRelease { sha256 = "sha256-JvJ7xlGw+tHtWje+jiQChVC4KTyqqdq2q+MIcOv/k1o="; }) + # 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 + # CREATE EXTENSION requires super-user privileges. To avoid that, we just skip # the responsible SQL statement here and take care of it in the module. ./skip-create-ext.patch @@ -60,25 +73,13 @@ in beamPackages.mixRelease { updateScript = ./update.sh; }; - postPatch = '' - # Without this modification, tzdata tries to write in its store-path: - # https://github.com/lau/tzdata#data-directory-and-releases - echo 'config :tzdata, :data_dir, (System.get_env("PLAUSIBLE_TZDATA") || "/tmp/plausible_tzdata")' \ - >> config/config.exs - ''; - - buildPhase = '' - runHook preBuild - - mkdir -p $out + 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 - - runHook postBuild ''; meta = with lib; { diff --git a/pkgs/servers/web-apps/plausible/tzdata-rebased.patch b/pkgs/servers/web-apps/plausible/tzdata-rebased.patch new file mode 100644 index 00000000000..462ab3cb6d6 --- /dev/null +++ b/pkgs/servers/web-apps/plausible/tzdata-rebased.patch @@ -0,0 +1,21 @@ +diff --git a/config/runtime.exs b/config/runtime.exs +index 7c9cc14..8facd05 100644 +--- a/config/runtime.exs ++++ b/config/runtime.exs +@@ -15,9 +15,7 @@ end + base_url = URI.parse(base_url) + + if base_url.scheme not in ["http", "https"] do +- raise "BASE_URL must start with `http` or `https`. Currently configured as `#{ +- System.get_env("BASE_URL") +- }`" ++ raise "BASE_URL must start with `http` or `https`. Currently configured as `#{System.get_env("BASE_URL")}`" + end + + secret_key_base = +@@ -300,3 +298,5 @@ if appsignal_api_key do + env: env, + active: true + end ++ ++config :tzdata, :data_dir, System.get_env("TZDATA_DIR", "priv")