···323324- Package `pash` was removed due to being archived upstream. Use `powershell` as an alternative.
32500326- `security.sudo.extraRules` now includes `root`'s default rule, with ordering
327 priority 400. This is functionally identical for users not specifying rule
328 order, or relying on `mkBefore` and `mkAfter`, but may impact users calling
···323324- Package `pash` was removed due to being archived upstream. Use `powershell` as an alternative.
325326+- The option `services.plausible.releaseCookiePath` has been removed: Plausible does not use any distributed Erlang features, and does not plan to (see [discussion](https://github.com/NixOS/nixpkgs/pull/130297#issuecomment-1805851333)), so NixOS now disables them, and the Erlang cookie becomes unnecessary. You may delete the file that `releaseCookiePath` was set to.
327+328- `security.sudo.extraRules` now includes `root`'s default rule, with ordering
329 priority 400. This is functionally identical for users not specifying rule
330 order, or relying on `mkBefore` and `mkAfter`, but may impact users calling
···1112 package = mkPackageOptionMD pkgs "plausible" { };
13000000014 adminUser = {
15 name = mkOption {
16 default = "admin";
···85 framework docs](https://hexdocs.pm/phoenix/Mix.Tasks.Phx.Gen.Secret.html#content).
86 '';
87 };
88+ listenAddress = mkOption {
89+ default = "127.0.0.1";
90+ type = types.str;
91+ description = lib.mdDoc ''
92+ The IP address on which the server is listening.
93+ '';
94+ };
95 port = mkOption {
96 default = 8000;
97 type = types.port;
···162 };
163 };
164165+ imports = [
166+ (mkRemovedOptionModule [ "services" "plausible" "releaseCookiePath" ] "Plausible uses no distributed Erlang features, so this option is no longer necessary and was removed")
167+ ];
168+169 config = mkIf cfg.enable {
170 assertions = [
171 { assertion = cfg.adminUser.activate -> cfg.database.postgres.setup;
···183 services.clickhouse = mkIf cfg.database.clickhouse.setup {
184 enable = true;
185 };
00186187 environment.systemPackages = [ cfg.package ];
188···211 # Configuration options from
212 # https://plausible.io/docs/self-hosting-configuration
213 PORT = toString cfg.server.port;
214+ LISTEN_IP = cfg.server.listenAddress;
215+216+ # Note [plausible-needs-no-erlang-distributed-features]:
217+ # Plausible does not use, and does not plan to use, any of
218+ # Erlang's distributed features, see:
219+ # https://github.com/plausible/analytics/pull/1190#issuecomment-1018820934
220+ # Thus, disable distribution for improved simplicity and security:
221+ #
222+ # When distribution is enabled,
223+ # Elixir spwans the Erlang VM, which will listen by default on all
224+ # interfaces for messages between Erlang nodes (capable of
225+ # remote code execution); it can be protected by a cookie; see
226+ # https://erlang.org/doc/reference_manual/distributed.html#security).
227+ #
228+ # It would be possible to restrict the interface to one of our choice
229+ # (e.g. localhost or a VPN IP) similar to how we do it with `listenAddress`
230+ # for the Plausible web server; if distribution is ever needed in the future,
231+ # https://github.com/NixOS/nixpkgs/pull/130297 shows how to do it.
232+ #
233+ # But since Plausible does not use this feature in any way,
234+ # we just disable it.
235+ RELEASE_DISTRIBUTION = "none";
236+ # Additional safeguard, in case `RELEASE_DISTRIBUTION=none` ever
237+ # stops disabling the start of EPMD.
238+ ERL_EPMD_ADDRESS = "127.0.0.1";
239+240 DISABLE_REGISTRATION = if isBool cfg.server.disableRegistration then boolToString cfg.server.disableRegistration else cfg.server.disableRegistration;
241242 RELEASE_TMP = "/var/lib/plausible/tmp";
···266 path = [ cfg.package ]
267 ++ optional cfg.database.postgres.setup config.services.postgresql.package;
268 script = ''
269+ # Elixir does not start up if `RELEASE_COOKIE` is not set,
270+ # even though we set `RELEASE_DISTRIBUTION=none` so the cookie should be unused.
271+ # Thus, make a random one, which should then be ignored.
272+ export RELEASE_COOKIE=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 20)
273 export ADMIN_USER_PWD="$(< $CREDENTIALS_DIRECTORY/ADMIN_USER_PWD )"
274 export SECRET_KEY_BASE="$(< $CREDENTIALS_DIRECTORY/SECRET_KEY_BASE )"
275···296 LoadCredential = [
297 "ADMIN_USER_PWD:${cfg.adminUser.passwordFile}"
298 "SECRET_KEY_BASE:${cfg.server.secretKeybaseFile}"
0299 ] ++ lib.optionals (cfg.mail.smtp.passwordFile != null) [ "SMTP_USER_PWD:${cfg.mail.smtp.passwordFile}"];
300 };
301 };