Skip to content

Commit ca14d62

Browse files
committed
ejabberd: withBootstrap flag for mod_invite
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.
1 parent c48f0f1 commit ca14d62

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

pkgs/by-name/ej/ejabberd/package.nix

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717
gd,
1818
autoreconfHook,
1919
gawk,
20+
applyPatches,
2021
fetchFromGitHub,
2122
fetchgit,
23+
fetchNpmDeps,
24+
fetchpatch2,
2225
beamPackages,
2326
nixosTests,
2427
withMysql ? false,
@@ -35,6 +38,9 @@
3538
withRedis ? false,
3639
withImagemagick ? false,
3740
imagemagick,
41+
withBootstrap ? true, # used for the built-in mod_invites page
42+
nodejs,
43+
npmHooks,
3844
}:
3945

4046
let
@@ -136,6 +142,7 @@ let
136142
"ezlib"
137143
];
138144

145+
npmToolingUsed = withBootstrap;
139146
in
140147
stdenv.mkDerivation (finalAttrs: {
141148
pname = "ejabberd";
@@ -150,6 +157,10 @@ stdenv.mkDerivation (finalAttrs: {
150157
rebar3_hex
151158
];
152159
})
160+
]
161+
++ lib.optionals npmToolingUsed [
162+
nodejs
163+
npmHooks.npmConfigHook
153164
];
154165

155166
buildInputs = [
@@ -165,13 +176,41 @@ stdenv.mkDerivation (finalAttrs: {
165176
++ lib.optional withLua allBeamDeps.luerl
166177
++ lib.optional withRedis allBeamDeps.eredis;
167178

179+
npmDeps =
180+
if npmToolingUsed then
181+
(fetchNpmDeps {
182+
name = "${finalAttrs.pname}-${finalAttrs.version}-npm-deps";
183+
src =
184+
if builtins.isNull finalAttrs.patches || builtins.length finalAttrs.patches <= 0 then
185+
finalAttrs.src
186+
else
187+
# A bit of a hack, but if the package*.json files are patched,
188+
# fetchNpmDeps will be out of sync
189+
applyPatches {
190+
inherit (finalAttrs) src patches;
191+
name = "${finalAttrs.pname}-patched";
192+
};
193+
hash = "sha256-MTyoc8ozrCi3W0CXmxyLpyU8v+vlUjcbLnv/1ev/Qqo=";
194+
})
195+
else
196+
null;
197+
168198
src = fetchFromGitHub {
169199
owner = "processone";
170200
repo = "ejabberd";
171201
tag = finalAttrs.version;
172202
hash = "sha256-M38niXEW++SPAvqQ2cqEd23+w7lBDO5EPgu/QRdYbXo=";
173203
};
174204

205+
patches = [
206+
(fetchpatch2 {
207+
# Makes Bootstrap optional, drops jQuery
208+
# https://github.com/processone/ejabberd/pull/4558
209+
url = "https://patch-diff.githubusercontent.com/raw/processone/ejabberd/pull/4558.patch";
210+
hash = "sha256-ONMQS7VRty6VYKVYcczEx9c/svqmyiTtZU/LAUz/PMY=";
211+
})
212+
];
213+
175214
passthru.tests = {
176215
inherit (nixosTests) ejabberd;
177216
};
@@ -186,10 +225,13 @@ stdenv.mkDerivation (finalAttrs: {
186225
(lib.enableFeature withLua "lua")
187226
(lib.enableFeature withTools "tools")
188227
(lib.enableFeature withRedis "redis")
228+
(lib.enableFeature withBootstrap "bootstrap")
189229
]
190230
++ lib.optional withSqlite "--with-sqlite3=${sqlite.dev}";
191231

192-
enableParallelBuilding = true;
232+
# The derivation wants to execute 2 dl_invites_page_deps.sh in parallel
233+
# causing unzip conflicts
234+
enableParallelBuilding = false;
193235

194236
postPatch = ''
195237
patchShebangs .
@@ -198,6 +240,10 @@ stdenv.mkDerivation (finalAttrs: {
198240
touch _build/default/lib/.built
199241
'';
200242

243+
preBuild = lib.optionalString npmToolingUsed /* sh */ ''
244+
npm run postinstall
245+
'';
246+
201247
env.REBAR_IGNORE_DEPS = 1;
202248

203249
postInstall = ''

0 commit comments

Comments
 (0)