From 289dbd83078373b2a54a1ea6b19829f8aeb06c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=B7=F0=90=91=91=F0=90=91=B4=F0=90=91=95=F0=90=91=91?= =?UTF-8?q?=F0=90=91=A9=F0=90=91=A4?= Date: Mon, 30 Mar 2026 22:28:37 +0700 Subject: [PATCH] ejabberd: withBootstrap flag for mod_invite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not ideal to pull in the npm toolchain just for getting some static files (this is upstream’s call), but is less maintenance than trying to track the versions ourselves. This also means now that if you don’t plan to use the built-in mod_invites page, you can opt out of the toolchain + dependency. --- pkgs/by-name/ej/ejabberd/package.nix | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pkgs/by-name/ej/ejabberd/package.nix b/pkgs/by-name/ej/ejabberd/package.nix index bdec28abbf8a..ac11b5094a1b 100644 --- a/pkgs/by-name/ej/ejabberd/package.nix +++ b/pkgs/by-name/ej/ejabberd/package.nix @@ -17,8 +17,11 @@ gd, autoreconfHook, gawk, + applyPatches, fetchFromGitHub, fetchgit, + fetchNpmDeps, + fetchpatch2, beamPackages, nixosTests, withMysql ? false, @@ -35,6 +38,9 @@ withRedis ? false, withImagemagick ? false, imagemagick, + withBootstrap ? true, # used for the built-in mod_invites page + nodejs, + npmHooks, }: let @@ -136,6 +142,7 @@ let "ezlib" ]; + npmToolingUsed = withBootstrap; in stdenv.mkDerivation (finalAttrs: { pname = "ejabberd"; @@ -150,6 +157,10 @@ stdenv.mkDerivation (finalAttrs: { rebar3_hex ]; }) + ] + ++ lib.optionals npmToolingUsed [ + nodejs + npmHooks.npmConfigHook ]; buildInputs = [ @@ -165,6 +176,21 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optional withLua allBeamDeps.luerl ++ lib.optional withRedis allBeamDeps.eredis; + npmDeps = lib.optionalDrvAttr npmToolingUsed (fetchNpmDeps { + name = "${finalAttrs.pname}-${finalAttrs.version}-npm-deps"; + src = + if builtins.isNull finalAttrs.patches || builtins.length finalAttrs.patches <= 0 then + finalAttrs.src + else + # A bit of a hack, but if the package*.json files are patched, + # fetchNpmDeps will be out of sync + applyPatches { + inherit (finalAttrs) src patches; + name = "${finalAttrs.pname}-${finalAttrs.version}-patched"; + }; + hash = "sha256-MTyoc8ozrCi3W0CXmxyLpyU8v+vlUjcbLnv/1ev/Qqo="; + }); + src = fetchFromGitHub { owner = "processone"; repo = "ejabberd"; @@ -172,6 +198,15 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-M38niXEW++SPAvqQ2cqEd23+w7lBDO5EPgu/QRdYbXo="; }; + patches = [ + (fetchpatch2 { + # Makes Bootstrap optional, drops jQuery + # https://github.com/processone/ejabberd/pull/4558 + url = "https://patch-diff.githubusercontent.com/raw/processone/ejabberd/pull/4558.patch"; + hash = "sha256-ETl2Zf7O6roxtf7DthJqL+tj4RvEfW94735sGM8x/GM="; + }) + ]; + passthru.tests = { inherit (nixosTests) ejabberd; }; @@ -186,6 +221,7 @@ stdenv.mkDerivation (finalAttrs: { (lib.enableFeature withLua "lua") (lib.enableFeature withTools "tools") (lib.enableFeature withRedis "redis") + (lib.enableFeature withBootstrap "bootstrap") ] ++ lib.optional withSqlite "--with-sqlite3=${sqlite.dev}"; @@ -198,6 +234,10 @@ stdenv.mkDerivation (finalAttrs: { touch _build/default/lib/.built ''; + preBuild = lib.optionalString npmToolingUsed /* sh */ '' + npm run postinstall + ''; + env.REBAR_IGNORE_DEPS = 1; postInstall = ''