Skip to content

Commit ac798c2

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 1b219c5 commit ac798c2

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

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

Lines changed: 44 additions & 0 deletions
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}-${finalAttrs.version}-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-ETl2Zf7O6roxtf7DthJqL+tj4RvEfW94735sGM8x/GM=";
211+
})
212+
];
213+
175214
passthru.tests = {
176215
inherit (nixosTests) ejabberd;
177216
};
@@ -186,6 +225,7 @@ 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

@@ -198,6 +238,10 @@ stdenv.mkDerivation (finalAttrs: {
198238
touch _build/default/lib/.built
199239
'';
200240

241+
preBuild = lib.optionalString npmToolingUsed /* sh */ ''
242+
npm run postinstall
243+
'';
244+
201245
env.REBAR_IGNORE_DEPS = 1;
202246

203247
postInstall = ''

0 commit comments

Comments
 (0)