Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 46 additions & 3 deletions pkgs/by-name/ej/ejabberd/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
gd,
autoreconfHook,
gawk,
applyPatches,
fetchFromGitHub,
fetchgit,
fetchNpmDeps,
fetchpatch2,
beamPackages,
nixosTests,
withMysql ? false,
Expand All @@ -35,6 +38,9 @@
withRedis ? false,
withImagemagick ? false,
imagemagick,
withBootstrap ? true, # used for the built-in mod_invites page
nodejs,
npmHooks,
}:

let
Expand Down Expand Up @@ -76,7 +82,6 @@ let
builder = lib.makeOverridable buildRebar3;

overrides = final: prev: {
jiffy = prev.jiffy.override { buildPlugins = [ beamPackages.pc ]; };
cache_tab = prev.cache_tab.override { buildPlugins = [ beamPackages.pc ]; };
mqtree = prev.mqtree.override { buildPlugins = [ beamPackages.pc ]; };
stringprep = prev.stringprep.override { buildPlugins = [ beamPackages.pc ]; };
Expand Down Expand Up @@ -137,10 +142,11 @@ let
"ezlib"
];

npmToolingUsed = withBootstrap;
in
stdenv.mkDerivation (finalAttrs: {
pname = "ejabberd";
version = "26.02";
version = "26.03";

nativeBuildInputs = [
makeWrapper
Expand All @@ -151,6 +157,10 @@ stdenv.mkDerivation (finalAttrs: {
rebar3_hex
];
})
]
++ lib.optionals npmToolingUsed [
nodejs
npmHooks.npmConfigHook
];

buildInputs = [
Expand All @@ -166,13 +176,41 @@ stdenv.mkDerivation (finalAttrs: {
++ lib.optional withLua allBeamDeps.luerl
++ 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.

(fetchNpmDeps {
name = "${finalAttrs.pname}-${finalAttrs.version}-npm-deps";
src =
if builtins.isNull finalAttrs.patches || builtins.length finalAttrs.patches <= 0 then
finalAttrs.src
else
Comment on lines +184 to +186
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

# A bit of a hack, but if the package*.json files are patched,
# fetchNpmDeps will be out of sync
Comment on lines +187 to +188
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”.

applyPatches {
inherit (finalAttrs) src patches;
name = "${finalAttrs.pname}-${finalAttrs.version}-patched";
};
hash = "sha256-MTyoc8ozrCi3W0CXmxyLpyU8v+vlUjcbLnv/1ev/Qqo=";
})
else
null;
Comment on lines +179 to +196
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.


src = fetchFromGitHub {
owner = "processone";
repo = "ejabberd";
tag = finalAttrs.version;
hash = "sha256-izP7Rz65Lr4LDOCzZPdDWb3TyXDSTd/8gOPSfovVGM8=";
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";
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.

hash = "sha256-ETl2Zf7O6roxtf7DthJqL+tj4RvEfW94735sGM8x/GM=";
})
];

passthru.tests = {
inherit (nixosTests) ejabberd;
};
Expand All @@ -187,6 +225,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}";

Expand All @@ -199,6 +238,10 @@ stdenv.mkDerivation (finalAttrs: {
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 */ ''

npm run postinstall
'';

env.REBAR_IGNORE_DEPS = 1;

postInstall = ''
Expand Down
138 changes: 53 additions & 85 deletions pkgs/by-name/ej/ejabberd/rebar-deps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,23 @@ in
let
self = packages // (overrides self packages);
packages = with self; {
unicode_util_compat = builder {
name = "unicode_util_compat";
version = "0.7.1";
src = fetchHex {
pkg = "unicode_util_compat";
version = "0.7.1";
sha256 = "sha256-s6kXhUzjriM2GXRK0eAQLgVnMTZ3b7L6diNPPgOyNkI=";
};
beamDeps = [ ];
};
jiffy = builder {
name = "jiffy";
version = "1.1.2";
src = fetchHex {
pkg = "jiffy";
version = "1.1.2";
sha256 = "sha256-u2G8Qqcgu9M8sJpBDki7eaYQEsdMuLPnXybZiEhc84E=";
};
beamDeps = [ ];
};
base64url = builder {
name = "base64url";
version = "1.0.1";
src = fetchHex {
pkg = "base64url";
version = "1.0.1";
sha256 = "sha256-+bOt1HMaAqmwQQOYtHWzPnVmppU2Ujemve4btEdxn1w=";
};
beamDeps = [ ];
};
yconf = builder {
name = "yconf";
version = "1.0.22";
version = "1.0.23";
src = fetchHex {
pkg = "yconf";
version = "1.0.22";
sha256 = "sha256-rKg0V86r5wdWSEtch7p7GVX1EdSZFoaH6uqnwwDoV/E=";
version = "1.0.23";
sha256 = "sha256-JbTft1MoAmrKp3TPXG+4fUi1XuvOYw3aozYkQdrDFDc=";
};
beamDeps = [ fast_yaml ];
};
xmpp = builder {
name = "xmpp";
version = "1.12.0";
version = "1.13.1";
src = fetchHex {
pkg = "xmpp";
version = "1.12.0";
sha256 = "sha256-AUuuc2WfuiVncesAe8U0hhiscn3R0QuasVqf74cWIsg=";
version = "1.13.1";
sha256 = "sha256-oCTu98y094uftS431jhaV73RUL515Q1Ru8uvOamriD0=";
};
beamDeps = [
ezlib
Expand All @@ -71,11 +41,11 @@ let
};
stun = builder {
name = "stun";
version = "1.2.21";
version = "1.2.22";
src = fetchHex {
pkg = "stun";
version = "1.2.21";
sha256 = "sha256-PX/o77nQWyQKaqmmv4uLe/8tgCiV0XBEPFiJh9weEtk=";
version = "1.2.22";
sha256 = "sha256-NAi0sR1SN6CI9TsmCgaUDDCxb0pICUiS1qkgThZDGIo=";
};
beamDeps = [
fast_tls
Expand All @@ -84,11 +54,11 @@ let
};
stringprep = builder {
name = "stringprep";
version = "1.0.33";
version = "1.0.34";
src = fetchHex {
pkg = "stringprep";
version = "1.0.33";
sha256 = "sha256-lvizC8UIh/YFsztGvKHSSMGah5MZuMSCeQ47TaXamMA=";
version = "1.0.34";
sha256 = "sha256-J+eOo3GIF2TgVvvoRdOtMEdA/14xMbwfOKZvC6qMm0c=";
};
beamDeps = [ p1_utils ];
};
Expand All @@ -114,23 +84,23 @@ let
};
p1_utils = builder {
name = "p1_utils";
version = "1.0.28";
version = "1.0.29";
src = fetchHex {
pkg = "p1_utils";
version = "1.0.28";
sha256 = "sha256-xJvUS8SkCtmWaRr4Jt1+CqVtTQzXMIFxkKH4TRp/ADM=";
version = "1.0.29";
sha256 = "sha256-IHFCHK21uP/xFOkdTZRPFIUcMyOR9uk/xQEarWSr4bk=";
};
beamDeps = [ ];
};
p1_pgsql = builder {
name = "p1_pgsql";
version = "1.1.38";
version = "1.1.41";
src = fetchHex {
pkg = "p1_pgsql";
version = "1.1.38";
sha256 = "sha256-Bs9kQwCBeOujh7ou6STTYgBBuuTaGyyWloAoSgXMdZ4=";
version = "1.1.41";
sha256 = "sha256-Ju4quj1FBGTt1LP/nassalP8ILv9Mwppc5grkGUEoXI=";
};
beamDeps = [ xmpp ];
beamDeps = [ stringprep ];
};
p1_oauth2 = builder {
name = "p1_oauth2";
Expand All @@ -144,37 +114,35 @@ let
};
p1_mysql = builder {
name = "p1_mysql";
version = "1.0.27";
version = "1.0.28";
src = fetchHex {
pkg = "p1_mysql";
version = "1.0.27";
sha256 = "sha256-BmBR8kACenZzJUfmnZagl05w3BTe2UU77yYyIYQe2ps=";
version = "1.0.28";
sha256 = "sha256-bk0A6OzlBbpQkcjas67+QVzy2Db/OVCDRMNSezZtmRk=";
};
beamDeps = [ ];
};
p1_acme = builder {
name = "p1_acme";
version = "1.0.30";
version = "1.0.31";
src = fetchHex {
pkg = "p1_acme";
version = "1.0.30";
sha256 = "sha256-KTXiCRa4BtOxFmlTpNkKaQ/YB4EJYUD+XKH2XVnr1oo=";
version = "1.0.31";
sha256 = "sha256-m1kiqQq5TaWInmTeXMrTrcbmim08P7cI3VA3V7Iy2xw=";
};
beamDeps = [
base64url
idna
jiffy
jose
yconf
];
};
mqtree = builder {
name = "mqtree";
version = "1.0.19";
version = "1.0.20";
src = fetchHex {
pkg = "mqtree";
version = "1.0.19";
sha256 = "sha256-yBBlcVxJoYgoEvgKWuLYQugN0/LRMFMN81mQJIv4zjw=";
version = "1.0.20";
sha256 = "sha256-XsDge5xIp4QGSWAL+W4UC0++nlAX4d3T6JjhXAo4PtA=";
};
beamDeps = [ p1_utils ];
};
Expand All @@ -200,61 +168,61 @@ let
};
idna = builder {
name = "idna";
version = "6.1.1";
version = "7.1.0";
src = fetchHex {
pkg = "idna";
version = "6.1.1";
sha256 = "sha256-kjdut4lEEu0ZrEdeSob3tBPBufu1vRbczVeTQVeUTOo=";
version = "7.1.0";
sha256 = "sha256-aulZoCW/Nt9hqMq4UI2WVIkbVCaoTETYLer/1t34xx8=";
};
beamDeps = [ unicode_util_compat ];
beamDeps = [ ];
};
fast_yaml = builder {
name = "fast_yaml";
version = "1.0.39";
version = "1.0.40";
src = fetchHex {
pkg = "fast_yaml";
version = "1.0.39";
sha256 = "sha256-JMe5q54rkmnWTkX0oqEoCWatsX0x5jNlz9PuJ3+wp40=";
version = "1.0.40";
sha256 = "sha256-J3BcKZAsHG8yaLqb84fV+pKLLmVbUxEPpHuOR20ys4Y=";
};
beamDeps = [ p1_utils ];
};
fast_xml = builder {
name = "fast_xml";
version = "1.1.57";
version = "1.1.58";
src = fetchHex {
pkg = "fast_xml";
version = "1.1.57";
sha256 = "sha256-7sNOkK2sr+Rn1d2rY1oBTe1zuYtAYVVLLRlyFz2SnDk=";
version = "1.1.58";
sha256 = "sha256-o21uA6OYxTuhiekSv0x1WaNwSsY8UFDxJtR0FAGLTKA=";
};
beamDeps = [ p1_utils ];
};
fast_tls = builder {
name = "fast_tls";
version = "1.1.25";
version = "1.1.26";
src = fetchHex {
pkg = "fast_tls";
version = "1.1.25";
sha256 = "sha256-WeGDtXQOZw4CuKpr5nO153eeX+W/zGef4tSZPRlJqCE=";
version = "1.1.26";
sha256 = "sha256-aw1N0jCQN1Zeuqms858CgI9fghWjkQGh2jPCpbG1mz8=";
};
beamDeps = [ p1_utils ];
};
ezlib = builder {
name = "ezlib";
version = "1.0.15";
version = "1.0.16";
src = fetchHex {
pkg = "ezlib";
version = "1.0.15";
sha256 = "sha256-3RS6bBJSGvXP5pI+c+PVRfSgiX3Ga/q1KH+7euOWLqs=";
version = "1.0.16";
sha256 = "sha256-tIGVQEA9Hst+rmRf3/FCqNsrR22JMojTm6u5KSIlBAU=";
};
beamDeps = [ p1_utils ];
};
esip = builder {
name = "esip";
version = "1.0.59";
version = "1.0.60";
src = fetchHex {
pkg = "esip";
version = "1.0.59";
sha256 = "sha256-C98uPDSdwLFE8XMVAynmdcalGsRz16Cy42IkX6rT++Y=";
version = "1.0.60";
sha256 = "sha256-BgTL1LvI2hWSwAgwz+MGIM5PZlurEZnRSjtF+v0DFE8=";
};
beamDeps = [
fast_tls
Expand Down Expand Up @@ -294,21 +262,21 @@ let
};
eimp = builder {
name = "eimp";
version = "1.0.26";
version = "1.0.27";
src = fetchHex {
pkg = "eimp";
version = "1.0.26";
sha256 = "sha256-2W1OhXK538QPJx5H8MsdiEk3O8mKISIyaHgXZe1SBEw=";
version = "1.0.27";
sha256 = "sha256-PH6D4pO8+vUKG/BU/Etit7jEhKbkIY45dwmk0NhX8/w=";
};
beamDeps = [ p1_utils ];
};
cache_tab = builder {
name = "cache_tab";
version = "1.0.33";
version = "1.0.34";
src = fetchHex {
pkg = "cache_tab";
version = "1.0.33";
sha256 = "sha256-QlgAnrBQsiqr4MhI4jC7pYQBpolcWML/dN+2NePDWQA=";
version = "1.0.34";
sha256 = "sha256-DbnzF/OUHBfJ+OqBJeJe+ie77Uy/JKQsQm+tp0yCtpI=";
};
beamDeps = [ p1_utils ];
};
Expand Down
Loading
Loading