1# The standard set of gems in nixpkgs including potential fixes.
2#
3# The gemset is derived from two points of entry:
4# - An attrset describing a gem, including version, source and dependencies
5# This is just meta data, most probably automatically generated by a tool
6# like Bundix (https://github.com/aflatter/bundix).
7# {
8# name = "bundler";
9# version = "1.6.5";
10# sha256 = "1s4x0f5by9xs2y24jk6krq5ky7ffkzmxgr4z1nhdykdmpsi2zd0l";
11# dependencies = [ "rake" ];
12# }
13# - An optional derivation that may override how the gem is built. For popular
14# gems that don't behave correctly, fixes are already provided in the form of
15# derivations.
16#
17# This seperates "what to build" (the exact gem versions) from "how to build"
18# (to make gems behave if necessary).
19
20{ lib, fetchurl, writeScript, ruby, kerberos, libxml2, libxslt, python, stdenv, which
21, libiconv, postgresql, v8_3_16_14, clang, sqlite, zlib, imagemagick
22, pkgconfig , ncurses, xapian_1_2_22, gpgme, utillinux, fetchpatch, tzdata, icu, libffi
23, cmake, libssh2, openssl, mysql, darwin, git, perl, pcre, gecode_3, curl
24, msgpack, qt59, libsodium, snappy, libossp_uuid, lxc, libpcap, xorg, gtk2, buildRubyGem
25, cairo, re2, rake, gobject-introspection, gdk_pixbuf, zeromq, czmq, graphicsmagick, libcxx
26, file, libvirt, glib, vips, taglib
27, libselinux ? null, libsepol ? null
28}@args:
29
30let
31 v8 = v8_3_16_14;
32
33 rainbow_rake = buildRubyGem {
34 pname = "rake";
35 gemName = "rake";
36 source.sha256 = "01j8fc9bqjnrsxbppncai05h43315vmz9fwg28qdsgcjw9ck1d7n";
37 type = "gem";
38 version = "12.0.0";
39 };
40in
41
42{
43 atk = attrs: {
44 nativeBuildInputs = [ pkgconfig ];
45 buildInputs = [ gtk2 pcre rake ];
46 };
47
48 bundler = attrs:
49 let
50 templates = "${attrs.ruby.gemPath}/gems/${attrs.gemName}-${attrs.version}/lib/bundler/templates/";
51 in {
52 # patching shebangs would fail on the templates/Executable file, so we
53 # temporarily remove the executable flag.
54 preFixup = "chmod -x $out/${templates}/Executable";
55 postFixup = ''
56 chmod +x $out/${templates}/Executable
57
58 # Allows to load another bundler version
59 sed -i -e "s/activate_bin_path/bin_path/g" $out/bin/bundle
60 '';
61 };
62
63 cairo = attrs: {
64 nativeBuildInputs = [ pkgconfig ];
65 buildInputs = [ gtk2 pcre xorg.libpthreadstubs xorg.libXdmcp];
66 };
67
68 cairo-gobject = attrs: {
69 nativeBuildInputs = [ pkgconfig ];
70 buildInputs = [ cairo pcre xorg.libpthreadstubs xorg.libXdmcp ];
71 };
72
73 capybara-webkit = attrs: {
74 buildInputs = [ qt59.qtbase qt59.qtwebkit ] ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ];
75 NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1";
76 };
77
78 charlock_holmes = attrs: {
79 buildInputs = [ which icu zlib ];
80 };
81
82 curb = attrs: {
83 buildInputs = [ curl ];
84 };
85
86 curses = attrs: {
87 buildInputs = [ ncurses ];
88 };
89
90 dep-selector-libgecode = attrs: {
91 USE_SYSTEM_GECODE = true;
92 postInstall = ''
93 installPath=$(cat $out/nix-support/gem-meta/install-path)
94 sed -i $installPath/lib/dep-selector-libgecode.rb -e 's@VENDORED_GECODE_DIR =.*@VENDORED_GECODE_DIR = "${gecode_3}"@'
95 '';
96 };
97
98 digest-sha3 = attrs: {
99 hardeningDisable = [ "format" ];
100 };
101
102 ethon = attrs: {
103 dontBuild = false;
104 postPatch = ''
105 substituteInPlace lib/ethon/curls/settings.rb \
106 --replace "libcurl" "${curl.out}/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary}"
107 '';
108 };
109
110 fog-dnsimple = attrs: {
111 postInstall = ''
112 cd $(cat $out/nix-support/gem-meta/install-path)
113 rm {$out/bin,bin,../../bin}/{setup,console}
114 '';
115 };
116
117 redis-rack = attrs: {
118 dontBuild = false;
119 preBuild = ''
120 exec 3>&1
121 output="$(gem build $gemspec | tee >(cat - >&3))"
122 exec 3>&-
123 sed -i 's!"rake".freeze!!' $gemspec
124 '';
125 };
126
127 ffi-rzmq-core = attrs: {
128 postInstall = ''
129 installPath=$(cat $out/nix-support/gem-meta/install-path)
130 sed -i $installPath/lib/ffi-rzmq-core/libzmq.rb -e 's@inside_gem =.*@inside_gem = "${zeromq}/lib"@'
131 '';
132 };
133
134 mini_magick = attrs: {
135 postInstall = ''
136 installPath=$(cat $out/nix-support/gem-meta/install-path)
137 echo -e "\nENV['PATH'] += ':${graphicsmagick}/bin'\n" >> $installPath/lib/mini_magick/configuration.rb
138 '';
139 };
140
141 do_sqlite3 = attrs: {
142 buildInputs = [ sqlite ];
143 };
144
145 eventmachine = attrs: {
146 buildInputs = [ openssl ];
147 };
148
149 ffi = attrs: {
150 nativeBuildInputs = [ pkgconfig ];
151 buildInputs = [ libffi ];
152 };
153
154 gdk_pixbuf2 = attrs: {
155 nativeBuildInputs = [ pkgconfig ];
156 buildInputs = [ rake gdk_pixbuf ];
157 };
158
159 gpgme = attrs: {
160 buildInputs = [ gpgme ];
161 };
162
163 gio2 = attrs: {
164 nativeBuildInputs = [ pkgconfig ];
165 buildInputs = [ gtk2 pcre gobject-introspection ] ++ lib.optionals stdenv.isLinux [ utillinux libselinux libsepol ];
166 };
167
168 gitlab-markup = attrs: { meta.priority = 1; };
169
170 glib2 = attrs: {
171 nativeBuildInputs = [ pkgconfig ];
172 buildInputs = [ gtk2 pcre ];
173 };
174
175 gtk2 = attrs: {
176 nativeBuildInputs = [ pkgconfig ] ++ lib.optionals stdenv.isLinux [ utillinux libselinux libsepol ];
177 buildInputs = [ gtk2 pcre xorg.libpthreadstubs xorg.libXdmcp];
178 # CFLAGS must be set for this gem to detect gdkkeysyms.h correctly
179 CFLAGS = "-I${gtk2.dev}/include/gtk-2.0 -I/non-existent-path";
180 };
181
182 gobject-introspection = attrs: {
183 nativeBuildInputs = [ pkgconfig ];
184 buildInputs = [ gobject-introspection gtk2 pcre ];
185 };
186
187 grpc = attrs: {
188 nativeBuildInputs = [ pkgconfig ];
189 buildInputs = [ openssl ];
190 hardeningDisable = [ "format" ];
191 NIX_CFLAGS_COMPILE = [ "-Wno-error=stringop-overflow" "-Wno-error=implicit-fallthrough" ];
192 };
193
194 hitimes = attrs: {
195 buildInputs =
196 stdenv.lib.optionals stdenv.isDarwin
197 [ darwin.apple_sdk.frameworks.CoreServices ];
198 };
199
200 iconv = attrs: {
201 buildFlags = lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
202 };
203
204 # disable bundle install as it can't install anything in addition to what is
205 # specified in pkgs/applications/misc/jekyll/Gemfile anyway. Also do chmod_R
206 # to compensate for read-only files in site_template in nix store.
207 jekyll = attrs: {
208 postInstall = ''
209 installPath=$(cat $out/nix-support/gem-meta/install-path)
210 sed -i $installPath/lib/jekyll/commands/new.rb \
211 -e 's@Exec.run("bundle", "install"@Exec.run("true"@' \
212 -e 's@FileUtils.cp_r site_template + "/.", path@FileUtils.cp_r site_template + "/.", path; FileUtils.chmod_R "u+w", path@'
213 '';
214 };
215
216 # note that you need version >= v3.16.14.8,
217 # otherwise the gem will fail to link to the libv8 binary.
218 # see: https://github.com/cowboyd/libv8/pull/161
219 libv8 = attrs: {
220 buildInputs = [ which v8 python ];
221 buildFlags = [ "--with-system-v8=true" ];
222 };
223
224 libxml-ruby = attrs: {
225 buildFlags = [
226 "--with-xml2-lib=${libxml2.out}/lib"
227 "--with-xml2-include=${libxml2.dev}/include/libxml2"
228 ];
229 };
230
231 magic = attrs: {
232 buildInputs = [ file ];
233 postInstall = ''
234 installPath=$(cat $out/nix-support/gem-meta/install-path)
235 sed -e 's@ENV\["MAGIC_LIB"\] ||@ENV\["MAGIC_LIB"\] || "${file}/lib/libmagic.so" ||@' -i $installPath/lib/magic/api.rb
236 '';
237 };
238
239 metasploit-framework = attrs: {
240 preInstall = ''
241 export HOME=$TMPDIR
242 '';
243 };
244
245 msgpack = attrs: {
246 buildInputs = [ msgpack ];
247 };
248
249 mysql = attrs: {
250 buildInputs = [ mysql.connector-c zlib openssl ];
251 };
252
253 mysql2 = attrs: {
254 buildInputs = [ mysql.connector-c zlib openssl ];
255 };
256
257 ncursesw = attrs: {
258 buildInputs = [ ncurses ];
259 buildFlags = [
260 "--with-cflags=-I${ncurses.dev}/include"
261 "--with-ldflags=-L${ncurses.out}/lib"
262 ];
263 };
264
265 nokogiri = attrs: {
266 buildFlags = [
267 "--use-system-libraries"
268 "--with-zlib-dir=${zlib.dev}"
269 "--with-xml2-lib=${libxml2.out}/lib"
270 "--with-xml2-include=${libxml2.dev}/include/libxml2"
271 "--with-xslt-lib=${libxslt.out}/lib"
272 "--with-xslt-include=${libxslt.dev}/include"
273 "--with-exslt-lib=${libxslt.out}/lib"
274 "--with-exslt-include=${libxslt.dev}/include"
275 ] ++ lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
276 };
277
278 ovirt-engine-sdk = attrs: {
279 buildInputs = [ curl libxml2 ];
280 };
281
282 pango = attrs: {
283 nativeBuildInputs = [ pkgconfig ];
284 buildInputs = [ gtk2 xorg.libXdmcp pcre xorg.libpthreadstubs ];
285 };
286
287 patron = attrs: {
288 buildInputs = [ curl ];
289 };
290
291 pcaprub = attrs: {
292 buildInputs = [ libpcap ];
293 };
294
295 pg = attrs: {
296 buildFlags = [
297 "--with-pg-config=${postgresql}/bin/pg_config"
298 ];
299 };
300
301 puma = attrs: {
302 buildInputs = [ openssl ];
303 };
304
305 rainbow = attrs: {
306 buildInputs = [ rainbow_rake ];
307 };
308
309 rbczmq = { ... }: {
310 buildInputs = [ zeromq czmq ];
311 buildFlags = [ "--with-system-libs" ];
312 };
313
314 rbnacl = spec:
315 if lib.versionOlder spec.version "6.0.0" then {
316 postInstall = ''
317 sed -i $(cat $out/nix-support/gem-meta/install-path)/lib/rbnacl.rb -e "2a \
318 RBNACL_LIBSODIUM_GEM_LIB_PATH = '${libsodium.out}/lib/libsodium${stdenv.hostPlatform.extensions.sharedLibrary}'
319 "
320 '';
321 } else {
322 buildInputs = [ libsodium ];
323 };
324
325 re2 = attrs: {
326 buildInputs = [ re2 ];
327 };
328
329 rmagick = attrs: {
330 nativeBuildInputs = [ pkgconfig ];
331 buildInputs = [ imagemagick which ];
332 };
333
334 ruby-libvirt = attrs: {
335 buildInputs = [ libvirt pkgconfig ];
336 buildFlags = [
337 "--with-libvirt-include=${libvirt}/include"
338 "--with-libvirt-lib=${libvirt}/lib"
339 ];
340 };
341
342 ruby-lxc = attrs: {
343 buildInputs = [ lxc ];
344 };
345
346 ruby-terminfo = attrs: {
347 buildInputs = [ ncurses ];
348 buildFlags = [
349 "--with-cflags=-I${ncurses.dev}/include"
350 "--with-ldflags=-L${ncurses.out}/lib"
351 ];
352 };
353
354 ruby-vips = attrs: {
355 postInstall = ''
356 cd "$(cat $out/nix-support/gem-meta/install-path)"
357
358 substituteInPlace lib/vips.rb \
359 --replace "glib-2.0" "${glib.out}/lib/libglib-2.0${stdenv.hostPlatform.extensions.sharedLibrary}"
360
361 substituteInPlace lib/vips.rb \
362 --replace "gobject-2.0" "${glib.out}/lib/libgobject-2.0${stdenv.hostPlatform.extensions.sharedLibrary}"
363
364 substituteInPlace lib/vips.rb \
365 --replace "vips_libname = 'vips'" "vips_libname = '${vips}/lib/libvips${stdenv.hostPlatform.extensions.sharedLibrary}'"
366 '';
367 };
368
369 rugged = attrs: {
370 nativeBuildInputs = [ pkgconfig ];
371 buildInputs = [ cmake openssl libssh2 zlib ];
372 dontUseCmakeConfigure = true;
373 };
374
375 sassc = attrs: {
376 nativeBuildInputs = [ rake ];
377 };
378
379 scrypt = attrs:
380 if stdenv.isDarwin then {
381 dontBuild = false;
382 postPatch = ''
383 sed -i -e "s/-arch i386//" Rakefile ext/scrypt/Rakefile
384 '';
385 } else {};
386
387 semian = attrs: {
388 buildInputs = [ openssl ];
389 };
390
391 sequel_pg = attrs: {
392 buildInputs = [ postgresql ];
393 };
394
395 snappy = attrs: {
396 buildInputs = [ args.snappy ];
397 };
398
399 sqlite3 = attrs: {
400 buildFlags = [
401 "--with-sqlite3-include=${sqlite.dev}/include"
402 "--with-sqlite3-lib=${sqlite.out}/lib"
403 ];
404 };
405
406 sup = attrs: {
407 dontBuild = false;
408 # prevent sup from trying to dynamically install `xapian-ruby`.
409 postPatch = ''
410 cp ${./mkrf_conf_xapian.rb} ext/mkrf_conf_xapian.rb
411
412 substituteInPlace lib/sup/crypto.rb \
413 --replace 'which gpg2' \
414 '${which}/bin/which gpg'
415 '';
416 };
417
418 rb-readline = attrs: {
419 dontBuild = false;
420 postPatch = ''
421 substituteInPlace lib/rbreadline.rb \
422 --replace 'infocmp' '${ncurses.dev}/bin/infocmp'
423 '';
424 };
425
426 taglib-ruby = attrs: {
427 buildInputs = [ taglib ];
428 };
429
430 thrift = attrs: {
431 # See: https://stackoverflow.com/questions/36378190/cant-install-thrift-gem-on-os-x-el-capitan/36523125#36523125
432 # Note that thrift-0.8.0 is a dependency of fluent-plugin-scribe which is a dependency of fluentd.
433 buildFlags = lib.optional (stdenv.isDarwin && lib.versionOlder attrs.version "0.9.2.0")
434 "--with-cppflags=\"-D_FORTIFY_SOURCE=0 -Wno-macro-redefined -Wno-shift-negative-value\"";
435 };
436
437 timfel-krb5-auth = attrs: {
438 buildInputs = [ kerberos ];
439 };
440
441 tiny_tds = attrs: {
442 nativeBuildInputs = [ pkgconfig openssl ];
443 };
444
445 therubyracer = attrs: {
446 buildFlags = [
447 "--with-v8-dir=${v8}"
448 "--with-v8-include=${v8}/include"
449 "--with-v8-lib=${v8}/lib"
450 ];
451 };
452
453 typhoeus = attrs: {
454 buildInputs = [ curl ];
455 };
456
457 tzinfo = attrs: lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") {
458 dontBuild = false;
459 postPatch =
460 let
461 path = if lib.versionAtLeast attrs.version "2.0"
462 then "lib/tzinfo/data_sources/zoneinfo_data_source.rb"
463 else "lib/tzinfo/zoneinfo_data_source.rb";
464 in
465 ''
466 substituteInPlace ${path} \
467 --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
468 '';
469 };
470
471 uuid4r = attrs: {
472 buildInputs = [ which libossp_uuid ];
473 };
474
475 xapian-ruby = attrs: {
476 # use the system xapian
477 dontBuild = false;
478 nativeBuildInputs = [ pkgconfig ];
479 buildInputs = [ xapian_1_2_22 zlib ];
480 postPatch = ''
481 cp ${./xapian-Rakefile} Rakefile
482 '';
483 preInstall = ''
484 export XAPIAN_CONFIG=${xapian_1_2_22}/bin/xapian-config
485 '';
486 };
487
488 zookeeper = attrs: {
489 buildInputs = stdenv.lib.optionals stdenv.isDarwin [ darwin.cctools ];
490 };
491
492}