Skip to content

ejabberd: 26.02 → 26.03#504293

Open
toastal wants to merge 3 commits intoNixOS:masterfrom
toastal:ejabberd-26.03
Open

ejabberd: 26.02 → 26.03#504293
toastal wants to merge 3 commits intoNixOS:masterfrom
toastal:ejabberd-26.03

Conversation

@toastal
Copy link
Copy Markdown
Contributor

@toastal toastal commented Mar 28, 2026

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

1

Footnotes

  1. Please consider giving up MS GitHub or offering a non-proprietary, non-US-corporate-controlled mirror for this free software project. I wish to delete this Microsoft account in the future, but I need more projects like this to support alternative methods to send patches & contribute.

@toastal toastal requested a review from chuangzhu March 28, 2026 05:53
@toastal
Copy link
Copy Markdown
Contributor Author

toastal commented Mar 28, 2026

@chuangzhujiffy is no longer in the rebar.lock. I assume it isn’t a dep?

Running phase: autoreconfPhase
autoreconf: export WARNINGS=
autoreconf: Entering directory '.'
...skipping...
chmod 755 ejabberd.init
tools/dl_invites_page_deps.sh: line 20: curl: command not found
make: *** [Makefile:236: priv/mod_invites/static/bootstrap/] Error 127
make: *** Waiting for unfinished jobs....
tools/dl_invites_page_deps.sh: line 20: curl: command not found
make: *** [Makefile:238: priv/mod_invites/static/jquery/] Error 127
===> Errors loading plugin configure_deps. Run rebar3 with DEBUG=1 set to see errors.
===> Errors loading plugin {pc,"~> 1.15.0"}. Run rebar3 with DEBUG=1 set to see errors.
===> Errors loading plugin {pc,"~> 1.15.0"}. Run rebar3 with DEBUG=1 set to see errors.
Ignoring deps...
===> App cache_tab is no longer needed and can be deleted.
===> App eimp is no longer needed and can be deleted.
===> App erlydtl is no longer needed and can be deleted.
===> App ezlib is no longer needed and can be deleted.
===> App fast_tls is no longer needed and can be deleted.
===> App fast_xml is no longer needed and can be deleted.
===> App fast_yaml is no longer needed and can be deleted.
===> App idna is no longer needed and can be deleted.
===> App jose is no longer needed and can be deleted.
===> App mqtree is no longer needed and can be deleted.
===> App p1_acme is no longer needed and can be deleted.
===> App p1_oauth2 is no longer needed and can be deleted.
===> App p1_utils is no longer needed and can be deleted.
===> App pkix is no longer needed and can be deleted.
===> App stringprep is no longer needed and can be deleted.
===> App stun is no longer needed and can be deleted.
===> App xmpp is no longer needed and can be deleted.
===> App yconf is no longer needed and can be deleted.
===> Analyzing applications...
===> Compiling ejabberd

I think it might be failing on getting Twitter Bootstrap & jQuery for mod_invites but doing that in the Makefile.

@nixpkgs-ci nixpkgs-ci bot added 8.has: package (update) This PR updates a package to a newer version 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Mar 28, 2026
@chuangzhu
Copy link
Copy Markdown
Contributor

I think it might be failing on getting Twitter Bootstrap & jQuery for mod_invites but doing that in the Makefile.

We actually have two options:

ifeq (, $(shell which npm))
  INSTALL_INVITES_DEPS=tools/dl_invites_page_deps.sh priv/mod_invites/static
else
  INSTALL_INVITES_DEPS=npm install
endif

If the deps get complicated, we can use something like buildNpmPackages. But for now that seemed like overengineering since there are only two deps. Patching tools/dl_invites_page_deps.sh seems more reasonable.

@chuangzhu
Copy link
Copy Markdown
Contributor

diff --git a/pkgs/by-name/ej/ejabberd/package.nix b/pkgs/by-name/ej/ejabberd/package.nix
index bdec28abbf8a..3ec1606bf4af 100644
--- a/pkgs/by-name/ej/ejabberd/package.nix
+++ b/pkgs/by-name/ej/ejabberd/package.nix
@@ -20,6 +20,8 @@
   fetchFromGitHub,
   fetchgit,
   beamPackages,
+  fetchurl,
+  unzip,
   nixosTests,
   withMysql ? false,
   withPgsql ? false,
@@ -136,6 +138,17 @@ let
     "ezlib"
   ];
 
+  invitePageDeps = {
+    jquery = fetchurl {
+      url = "https://code.jquery.com/jquery-4.0.0.min.js";
+      sha256 = "39a546ea9ad97f8bfaf5d3e0e8f8556adb415e470e59007ada9759dce472adaa";
+    };
+    bootstrap = fetchurl {
+      url = "https://github.com/twbs/bootstrap/releases/download/v5.3.8/bootstrap-5.3.8-dist.zip";
+      sha256 = "3258c873cbcb1e2d81f4374afea2ea6437d9eee9077041073fd81dd579c5ba6b";
+    };
+  };
+
 in
 stdenv.mkDerivation (finalAttrs: {
   pname = "ejabberd";
@@ -150,6 +163,7 @@ stdenv.mkDerivation (finalAttrs: {
         rebar3_hex
       ];
     })
+    unzip # invitePageDeps
   ];
 
   buildInputs = [
@@ -189,13 +203,19 @@ stdenv.mkDerivation (finalAttrs: {
   ]
   ++ lib.optional withSqlite "--with-sqlite3=${sqlite.dev}";
 
-  enableParallelBuilding = true;
+  # It wants to execute two dl_invites_page_deps.sh in parallel
+  # Causing unzip conflicts
+  enableParallelBuilding = false;
 
   postPatch = ''
     patchShebangs .
     mkdir -p _build/default/lib
     touch _build/default/lib/.got
     touch _build/default/lib/.built
+    sed -i \
+      -e 's|curl .* $jquery .*|cp ${invitePageDeps.jquery} $jquery|' \
+      -e 's|curl .* $bootstrap .*|cp ${invitePageDeps.bootstrap} $bootstrap|' \
+      tools/dl_invites_page_deps.sh
   '';
 
   env.REBAR_IGNORE_DEPS = 1;

@toastal
Copy link
Copy Markdown
Contributor Author

toastal commented Mar 30, 2026

That’s one solution… doesn’t scale the best. Since they use SRIs, if we don’t have our versions in sync with upstream, we won’t know about breakage until runtime where we don’t match their hashes—which could mean a NixOS upgrade could make the invites not work entirely. Had they not included SRIs on the page, it would probably be fine/safe to be slightly out of sync on versions.

I opened these upstream to see if they have any takes:

We could run the script in IFD perhaps to fetch (slow, but small deps) or use the npm Hooks (pulls in a massive, questionable toolchain just to fetch deps).

Additionally, since mod_invites can be disabled, I think they made the wrong choice requiring these dependencies.

@chuangzhu
Copy link
Copy Markdown
Contributor

chuangzhu commented Mar 30, 2026

we won’t know about breakage until runtime where we don’t match their hashes

I tested the patch I posted above with this:

diff --git a/pkgs/by-name/ej/ejabberd/package.nix b/pkgs/by-name/ej/ejabberd/package.nix
index 3ec1606bf4af..160967eed12e 100644
--- a/pkgs/by-name/ej/ejabberd/package.nix
+++ b/pkgs/by-name/ej/ejabberd/package.nix
@@ -140,8 +140,8 @@ let
 
   invitePageDeps = {
     jquery = fetchurl {
-      url = "https://code.jquery.com/jquery-4.0.0.min.js";
-      sha256 = "39a546ea9ad97f8bfaf5d3e0e8f8556adb415e470e59007ada9759dce472adaa";
+      url = "https://code.jquery.com/jquery-3.0.0.min.js";
+      sha256 = "266bcea0bb58b26aa5b16c5aee60d22ccc1ae9d67daeb21db6bad56119c3447d";
     };
     bootstrap = fetchurl {
       url = "https://github.com/twbs/bootstrap/releases/download/v5.3.8/bootstrap-5.3.8-dist.zip";

And it totally noticed the checksum mismatch:

ejabberd> tools/dl_invites_page_deps.sh priv/mod_invites/static
ejabberd> /tmp/jquery.DGdCBgFFs: FAILED
ejabberd> sha256sum: WARNING: 1 computed checksum did NOT match
ejabberd> checksum failed: /tmp/jquery.DGdCBgFFs (does not match 39a546ea9ad97f8bfaf5d3e0e8f8556adb415e470e59007ada9759dce472adaa)
ejabberd> make: *** [Makefile:236: priv/mod_invites/static/bootstrap/] Error 1
error: Cannot build '/nix/store/6k7852y0q84114cysr2y9yn303ikyvam-ejabberd-26.03.drv'.
       Reason: builder failed with exit code 2.
       Output paths:
         /nix/store/m43g3j8rw651rv85hvi250x134zy6y3n-ejabberd-26.03

I only changed curl to cp, I didn't delete the checksum logic.

@chuangzhu
Copy link
Copy Markdown
Contributor

I think they made the wrong choice requiring these dependencies.

I would argue it's not that bad (at least for now...). I've seen much worse

@toastal
Copy link
Copy Markdown
Contributor Author

toastal commented Mar 30, 2026

I see what you did, but was I hoping we can have a better solution.

However, having thought on it a bit, this could be good enough for now as it likely won’t be addressed in the near term. Hopefully it can trip on the version with diff not being very smart to catch version mismatches.

I’d rather they ripped the SRIs out so I could recompile Bootstrap for a specific target (meaning Browserslist) or in line with 5.x upstream generally vs. Ejabberd’s specific version. Subresource integrity is best for using with third-party scripts (never ideal) & since these deps are already vendored & checked with their hashes, I don’t know what they are getting out of checking again at runtime.

I would argue it's not that bad (at least for now...). I've seen much worse

True, but it also doesn’t make a lot of sense since a) you can disable the module & b) the docs say you can point to your own endpoint… both of which don’t need it.

@chuangzhu chuangzhu requested a review from a team March 30, 2026 12:07
@toastal toastal force-pushed the ejabberd-26.03 branch 2 times, most recently from 499007c to 8e64623 Compare March 30, 2026 15:28
@adamcstephens
Copy link
Copy Markdown
Contributor

While I have little skin in this game, I would recommend accepting that there's now nodejs in this package and using standard npm fetchers/builders.Using fetchers like this is a bit too much of a hack around the problem, in my opinion.

# despite every indication that it should be. Hopefully this is temporary.
# See: https://github.com/processone/ejabberd/issues/4554
invitePageDeps = {
# Ideally this could be removed too as jQuery isn’t Bootstrap 5.x requirement

This comment was marked as off-topic.

@toastal
Copy link
Copy Markdown
Contributor Author

toastal commented Mar 30, 2026

I had looked into the npm option in the WIP (now reverted), but I didn’t like the way it was going just to fetch 2 dependencies. Since I thought this was not very good design, I reported it on their bug tracker & would rather see upstream’s response. At least we could gate Node.js behind withInvitePageDeps ? true/false in future versions if they agree the design should be better.

Sorry, this whole issue really frustrated me being a, well I guess now ex-, front-end developer.

@toastal toastal force-pushed the ejabberd-26.03 branch 3 times, most recently from aed32d4 to ca14d62 Compare April 3, 2026 09:35
@toastal
Copy link
Copy Markdown
Contributor Author

toastal commented Apr 3, 2026

@chuangzhu @adamcstephens I patched with their open merge request to make Bootstrap optional (+ removing jQuery <3). This means users can opt out of the heft of the npm ecosystem if desired.

What I mostly need help with: what is the default? withBootstrap ? true or withBootstarp ? false?

@toastal toastal requested a review from chuangzhu April 3, 2026 09:37
@toastal toastal force-pushed the ejabberd-26.03 branch 2 times, most recently from 33bea0a to 6615532 Compare April 3, 2026 09:40
@adamcstephens
Copy link
Copy Markdown
Contributor

adamcstephens commented Apr 3, 2026

I personally prefer to ship things as upstream intends with all features available, and let users that want to optimize override to do so. So I’d recommend enabled by default.

Comment on lines +179 to +196
npmDeps =
if npmToolingUsed then
(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=";
})
else
null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand your concern of jQuery being unnecessary, but I would rather ship jQuery than this...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume these flags + dropping jQuery are going to be merged for the next release since someone else opened the merge request… which to me would mean adding support for jQuery for 1 patch isn’t super useful.

pkgs.exatorrent.override { withUI = false; } takes this same approach (but doesn’t handle if patches are applied). The applyPatches could potentially be dropped once merged under the assumption folks generally won’t be needing to patch the package.json or package-lock.json.

What we get is the ability to not think about the version the are shipping, changing the update script.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could wait the upstream to release a new version. Cleaning their code isn't our job. Patches are used for something more critical. Your attempt to smuggle the patch just looks terrible

Copy link
Copy Markdown
Contributor Author

@toastal toastal Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think seding the build script & adding dependencies to manually track is worse as even upstream has recognized the issue we had to hack around—& I would argue the patch unblocking the build while allowing Nix users to opt it/out is important (tho maybe waiting til it is merged makes more sense).

I’m actively already using this patch to test out the feature for my use case which I why I want it working without sending useless jQuery to my users (my users will be on metered mobile data). I can continue using this patch for my own setup until the next release, but I think this npm-based solution is going to be the easiest to manage long term as @adamcstephens was also suggesting—even if I hate Node.js now needing to be a nativeBuildInputs (otherwise trying to keep sync with their front-end deps is going to be unfun).

I’m not really sure what is wrong with this code block tho as it does exactly what it needs to do: 1) don’t pull in Node.js/npm if not used/needed (currently just withBootstrap), 2) use the package*.json files from the src, 3) patch the source if there are patches since AFAICT, there is no finalAttrs.finalResolvedSrc. Even if/when merged & with a new release, I don’t know that this block would want to change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ugly and complex. Either we remove it unconditional or not. Either is fine for me.

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.
old_version=$(nix-instantiate --eval -A ejabberd.version | jq -e -r)

if [[ $version == "$old_version" ]]; then
if [ "$version" = "$old_version" ]; then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we remove bashism in a script that is always executed by bash?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s better to wrap the variable in a string in scripts. If touching the line, I don’t see why not increase compatibility in favor of Bash—what is Bash even getting you over POSIX [?

touch _build/default/lib/.built
'';

preBuild = lib.optionalString npmToolingUsed /* sh */ ''
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
preBuild = lib.optionalString npmToolingUsed /* sh */ ''
preBuild = lib.optionalString npmToolingUsed /* bash */ ''

(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";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not merged, we must vendor the patch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the consensus is that this release isn’t going to be merged at all since that patch isn’t in the version.

Comment on lines +184 to +186
if builtins.isNull finalAttrs.patches || builtins.length finalAttrs.patches <= 0 then
finalAttrs.src
else
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if builtins.isNull finalAttrs.patches || builtins.length finalAttrs.patches <= 0 then
finalAttrs.src
else

Comment on lines +187 to +188
# A bit of a hack, but if the package*.json files are patched,
# fetchNpmDeps will be out of sync
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# A bit of a hack, but if the package*.json files are patched,
# fetchNpmDeps will be out of sync

I think this is expected

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everyone I have asked seems to have questions about this line since it lacks immediate intuition for “why”.

++ lib.optional withRedis allBeamDeps.eredis;

npmDeps =
if npmToolingUsed then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if npmToolingUsed then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn’t work. The current setup allows Nixpkgs Ejabberd users to opt out (override { withBootstrap = false; }) of the npm toolchain if not using Bootstrap. This boolean gates pulling in such a large (but maintainable) toolchain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

8.has: package (update) This PR updates a package to a newer version 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants