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, gpgme, utillinux, 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, libopus, linux-pam, libidn, protobuf, fribidi, harfbuzz
27, bison, flex, pango, python3, patchelf, binutils, freetds, wrapGAppsHook, atk
28, bundler, libsass, libselinux ? null, libsepol ? null
29}@args:
30
31let
32 v8 = v8_3_16_14;
33
34 rainbow_rake = buildRubyGem {
35 pname = "rake";
36 gemName = "rake";
37 source.sha256 = "01j8fc9bqjnrsxbppncai05h43315vmz9fwg28qdsgcjw9ck1d7n";
38 type = "gem";
39 version = "12.0.0";
40 };
41in
42
43{
44 atk = attrs: {
45 dependencies = attrs.dependencies ++ [ "gobject-introspection" ];
46 nativeBuildInputs = [ rake bundler pkgconfig ];
47 propagatedBuildInputs = [ gobject-introspection wrapGAppsHook atk ];
48 };
49
50 bundler = attrs:
51 let
52 templates = "${attrs.ruby.gemPath}/gems/${attrs.gemName}-${attrs.version}/lib/bundler/templates/";
53 in {
54 # patching shebangs would fail on the templates/Executable file, so we
55 # temporarily remove the executable flag.
56 preFixup = "chmod -x $out/${templates}/Executable";
57 postFixup = ''
58 chmod +x $out/${templates}/Executable
59
60 # Allows to load another bundler version
61 sed -i -e "s/activate_bin_path/bin_path/g" $out/bin/bundle
62 '';
63 };
64
65 cairo = attrs: {
66 nativeBuildInputs = [ pkgconfig ];
67 buildInputs = [ gtk2 pcre xorg.libpthreadstubs xorg.libXdmcp];
68 };
69
70 cairo-gobject = attrs: {
71 nativeBuildInputs = [ pkgconfig ];
72 buildInputs = [ cairo pcre xorg.libpthreadstubs xorg.libXdmcp ];
73 };
74
75 capybara-webkit = attrs: {
76 buildInputs = [ qt59.qtbase qt59.qtwebkit ] ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ];
77 NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1";
78 };
79
80 charlock_holmes = attrs: {
81 buildInputs = [ which icu zlib ];
82 };
83
84 cld3 = attrs: {
85 nativeBuildInputs = [ pkgconfig ];
86 buildInputs = [ protobuf ];
87 };
88
89 cocoapods-acknowledgements = attrs: {
90 dependencies = attrs.dependencies ++ [ "cocoapods" ];
91 };
92
93 cocoapods-deploy = attrs: {
94 dependencies = [ "cocoapods" ];
95 };
96
97 cocoapods-disable-podfile-validations = attrs: {
98 dependencies = [ "cocoapods" ];
99 };
100
101 cocoapods-generate = attrs: {
102 dependencies = attrs.dependencies ++ [ "cocoapods" ];
103 };
104
105 cocoapods-git_url_rewriter = attrs: {
106 dependencies = [ "cocoapods" ];
107 };
108
109 cocoapods-keys = attrs: {
110 dependencies = attrs.dependencies ++ [ "cocoapods" ];
111 };
112
113 cocoapods-open = attrs: {
114 dependencies = [ "cocoapods" ];
115 };
116
117 cocoapods-try-release-fix = attrs: {
118 dependencies = [ "cocoapods" ];
119 };
120
121 curb = attrs: {
122 buildInputs = [ curl ];
123 };
124
125 curses = attrs: {
126 buildInputs = [ ncurses ];
127 };
128
129 dep-selector-libgecode = attrs: {
130 USE_SYSTEM_GECODE = true;
131 postInstall = ''
132 installPath=$(cat $out/nix-support/gem-meta/install-path)
133 sed -i $installPath/lib/dep-selector-libgecode.rb -e 's@VENDORED_GECODE_DIR =.*@VENDORED_GECODE_DIR = "${gecode_3}"@'
134 '';
135 };
136
137 digest-sha3 = attrs: {
138 hardeningDisable = [ "format" ];
139 };
140
141 ethon = attrs: {
142 dontBuild = false;
143 postPatch = ''
144 substituteInPlace lib/ethon/curls/settings.rb \
145 --replace "libcurl" "${curl.out}/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary}"
146 '';
147 };
148
149 fog-dnsimple = attrs:
150 lib.optionalAttrs (lib.versionOlder attrs.version "1.0.1") {
151 postInstall = ''
152 cd $(cat $out/nix-support/gem-meta/install-path)
153 rm {$out/bin,bin,../../bin}/{setup,console}
154 '';
155 };
156
157 redis-rack = attrs: {
158 dontBuild = false;
159 preBuild = ''
160 exec 3>&1
161 output="$(gem build $gemspec | tee >(cat - >&3))"
162 exec 3>&-
163 sed -i 's!"rake".freeze!!' $gemspec
164 '';
165 };
166
167 ffi-rzmq-core = attrs: {
168 postInstall = ''
169 installPath=$(cat $out/nix-support/gem-meta/install-path)
170 sed -i $installPath/lib/ffi-rzmq-core/libzmq.rb -e 's@inside_gem =.*@inside_gem = "${zeromq}/lib"@'
171 '';
172 };
173
174 mini_magick = attrs: {
175 postInstall = ''
176 installPath=$(cat $out/nix-support/gem-meta/install-path)
177 echo -e "\nENV['PATH'] += ':${graphicsmagick}/bin'\n" >> $installPath/lib/mini_magick/configuration.rb
178 '';
179 };
180
181 do_sqlite3 = attrs: {
182 buildInputs = [ sqlite ];
183 };
184
185 eventmachine = attrs: {
186 buildInputs = [ openssl ];
187 };
188
189 ffi = attrs: {
190 nativeBuildInputs = [ pkgconfig ];
191 buildInputs = [ libffi ];
192 };
193
194 gdk_pixbuf2 = attrs: {
195 nativeBuildInputs = [ pkgconfig bundler rake ];
196 propagatedBuildInputs = [ gobject-introspection wrapGAppsHook gdk-pixbuf ];
197 };
198
199 gpgme = attrs: {
200 buildInputs = [ gpgme ];
201 buildFlags = [ "--use-system-libraries" ];
202 };
203
204 gio2 = attrs: {
205 nativeBuildInputs = [ pkgconfig ];
206 buildInputs = [ gtk2 pcre gobject-introspection ] ++ lib.optionals stdenv.isLinux [ utillinux libselinux libsepol ];
207 };
208
209 gitlab-markup = attrs: { meta.priority = 1; };
210
211 glib2 = attrs: {
212 nativeBuildInputs = [ pkgconfig ];
213 buildInputs = [ gtk2 pcre ];
214 };
215
216 gtk2 = attrs: {
217 nativeBuildInputs = [
218 binutils pkgconfig
219 ] ++ lib.optionals stdenv.isLinux [
220 utillinux libselinux libsepol
221 ];
222 propagatedBuildInputs = [
223 atk
224 gdk-pixbuf
225 fribidi
226 gobject-introspection
227 gtk2
228 harfbuzz
229 pcre
230 xorg.libpthreadstubs
231 xorg.libXdmcp
232 ];
233 # CFLAGS must be set for this gem to detect gdkkeysyms.h correctly
234 # CFLAGS = "-I${gtk2.dev}/include/gtk-2.0 -I/non-existent-path";
235 };
236
237 gobject-introspection = attrs: {
238 nativeBuildInputs = [ pkgconfig pcre ];
239 propagatedBuildInputs = [ gobject-introspection wrapGAppsHook glib ];
240 };
241
242 grpc = attrs: {
243 nativeBuildInputs = [ pkgconfig ];
244 buildInputs = [ openssl ];
245 hardeningDisable = [ "format" ];
246 NIX_CFLAGS_COMPILE = [
247 "-Wno-error=stringop-overflow"
248 "-Wno-error=implicit-fallthrough"
249 "-Wno-error=sizeof-pointer-memaccess"
250 "-Wno-error=cast-function-type"
251 "-Wno-error=class-memaccess"
252 "-Wno-error=ignored-qualifiers"
253 "-Wno-error=tautological-compare"
254 ];
255 dontBuild = false;
256 postPatch = ''
257 substituteInPlace Makefile \
258 --replace '-Wno-invalid-source-encoding' ""
259 '';
260 };
261
262 hitimes = attrs: {
263 buildInputs =
264 stdenv.lib.optionals stdenv.isDarwin
265 [ darwin.apple_sdk.frameworks.CoreServices ];
266 };
267
268 iconv = attrs: {
269 buildFlags = lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
270 };
271
272 idn-ruby = attrs: {
273 buildInputs = [ libidn ];
274 };
275
276 # disable bundle install as it can't install anything in addition to what is
277 # specified in pkgs/applications/misc/jekyll/Gemfile anyway. Also do chmod_R
278 # to compensate for read-only files in site_template in nix store.
279 jekyll = attrs: {
280 postInstall = ''
281 installPath=$(cat $out/nix-support/gem-meta/install-path)
282 sed -i $installPath/lib/jekyll/commands/new.rb \
283 -e 's@Exec.run("bundle", "install"@Exec.run("true"@' \
284 -e 's@FileUtils.cp_r site_template + "/.", path@FileUtils.cp_r site_template + "/.", path; FileUtils.chmod_R "u+w", path@'
285 '';
286 };
287
288 # note that you need version >= v3.16.14.8,
289 # otherwise the gem will fail to link to the libv8 binary.
290 # see: https://github.com/cowboyd/libv8/pull/161
291 libv8 = attrs: {
292 buildInputs = [ which v8 python ];
293 buildFlags = [ "--with-system-v8=true" ];
294 };
295
296 execjs = attrs: {
297 propagatedBuildInputs = [ v8 ];
298 };
299
300 libxml-ruby = attrs: {
301 buildFlags = [
302 "--with-xml2-lib=${libxml2.out}/lib"
303 "--with-xml2-include=${libxml2.dev}/include/libxml2"
304 ];
305 };
306
307 mathematical = attrs: {
308 buildInputs = [
309 cmake
310 bison
311 flex
312 glib
313 pkgconfig
314 cairo
315 pango
316 gdk-pixbuf
317 libxml2
318 python3
319 ];
320
321 # The ruby build script takes care of this
322 dontUseCmakeConfigure = true;
323
324 # For some reason 'mathematical.so' is missing cairo and glib in its RPATH, add them explicitly here
325 postFixup = lib.optionalString stdenv.isLinux ''
326 soPath="$out/${ruby.gemPath}/gems/mathematical-${attrs.version}/lib/mathematical/mathematical.so"
327 ${patchelf}/bin/patchelf \
328 --set-rpath "${lib.makeLibraryPath [ glib cairo ]}:$(${patchelf}/bin/patchelf --print-rpath "$soPath")" \
329 "$soPath"
330 '';
331 };
332
333 magic = attrs: {
334 buildInputs = [ file ];
335 postInstall = ''
336 installPath=$(cat $out/nix-support/gem-meta/install-path)
337 sed -e 's@ENV\["MAGIC_LIB"\] ||@ENV\["MAGIC_LIB"\] || "${file}/lib/libmagic.so" ||@' -i $installPath/lib/magic/api.rb
338 '';
339 };
340
341 metasploit-framework = attrs: {
342 preInstall = ''
343 export HOME=$TMPDIR
344 '';
345 };
346
347 msgpack = attrs: {
348 buildInputs = [ msgpack ];
349 };
350
351 mysql = attrs: {
352 buildInputs = [ mysql.connector-c zlib openssl ];
353 };
354
355 mysql2 = attrs: {
356 buildInputs = [ mysql.connector-c zlib openssl ];
357 };
358
359 ncursesw = attrs: {
360 buildInputs = [ ncurses ];
361 buildFlags = [
362 "--with-cflags=-I${ncurses.dev}/include"
363 "--with-ldflags=-L${ncurses.out}/lib"
364 ];
365 };
366
367 nokogiri = attrs: {
368 buildFlags = [
369 "--use-system-libraries"
370 "--with-zlib-dir=${zlib.dev}"
371 "--with-xml2-lib=${libxml2.out}/lib"
372 "--with-xml2-include=${libxml2.dev}/include/libxml2"
373 "--with-xslt-lib=${libxslt.out}/lib"
374 "--with-xslt-include=${libxslt.dev}/include"
375 "--with-exslt-lib=${libxslt.out}/lib"
376 "--with-exslt-include=${libxslt.dev}/include"
377 ] ++ lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
378 };
379
380 opus-ruby = attrs: {
381 dontBuild = false;
382 postPatch = ''
383 substituteInPlace lib/opus-ruby.rb \
384 --replace "ffi_lib 'opus'" \
385 "ffi_lib '${libopus}/lib/libopus${stdenv.hostPlatform.extensions.sharedLibrary}'"
386 '';
387 };
388
389 ovirt-engine-sdk = attrs: {
390 buildInputs = [ curl libxml2 ];
391 };
392
393 pango = attrs: {
394 nativeBuildInputs = [
395 pkgconfig
396 fribidi
397 harfbuzz
398 pcre
399 xorg.libpthreadstubs
400 xorg.libXdmcp
401 ];
402 propagatedBuildInputs = [ gobject-introspection wrapGAppsHook gtk2 ];
403 };
404
405 patron = attrs: {
406 buildInputs = [ curl ];
407 };
408
409 pcaprub = attrs: {
410 buildInputs = [ libpcap ];
411 };
412
413 pg = attrs: {
414 buildFlags = [
415 "--with-pg-config=${postgresql}/bin/pg_config"
416 ];
417 };
418
419 puma = attrs: {
420 buildInputs = [ openssl ];
421 };
422
423 rainbow = attrs: {
424 buildInputs = [ rainbow_rake ];
425 };
426
427 rbczmq = { ... }: {
428 buildInputs = [ zeromq czmq ];
429 buildFlags = [ "--with-system-libs" ];
430 };
431
432 rbnacl = spec:
433 if lib.versionOlder spec.version "6.0.0" then {
434 postInstall = ''
435 sed -i $(cat $out/nix-support/gem-meta/install-path)/lib/rbnacl.rb -e "2a \
436 RBNACL_LIBSODIUM_GEM_LIB_PATH = '${libsodium.out}/lib/libsodium${stdenv.hostPlatform.extensions.sharedLibrary}'
437 "
438 '';
439 } else {
440 dontBuild = false;
441 postPatch = ''
442 substituteInPlace lib/rbnacl/sodium.rb \
443 --replace 'ffi_lib ["sodium"' \
444 'ffi_lib ["${libsodium}/lib/libsodium${stdenv.hostPlatform.extensions.sharedLibrary}"'
445 '';
446 };
447
448 re2 = attrs: {
449 buildInputs = [ re2 ];
450 };
451
452 rmagick = attrs: {
453 nativeBuildInputs = [ pkgconfig ];
454 buildInputs = [ imagemagick which ];
455 };
456
457 rpam2 = attrs: {
458 buildInputs = [ linux-pam ];
459 };
460
461 ruby-libvirt = attrs: {
462 buildInputs = [ libvirt pkgconfig ];
463 buildFlags = [
464 "--with-libvirt-include=${libvirt}/include"
465 "--with-libvirt-lib=${libvirt}/lib"
466 ];
467 };
468
469 ruby-lxc = attrs: {
470 buildInputs = [ lxc ];
471 };
472
473 ruby-terminfo = attrs: {
474 buildInputs = [ ncurses ];
475 buildFlags = [
476 "--with-cflags=-I${ncurses.dev}/include"
477 "--with-ldflags=-L${ncurses.out}/lib"
478 ];
479 };
480
481 ruby-vips = attrs: {
482 postInstall = ''
483 cd "$(cat $out/nix-support/gem-meta/install-path)"
484
485 substituteInPlace lib/vips.rb \
486 --replace "glib-2.0" "${glib.out}/lib/libglib-2.0${stdenv.hostPlatform.extensions.sharedLibrary}"
487
488 substituteInPlace lib/vips.rb \
489 --replace "gobject-2.0" "${glib.out}/lib/libgobject-2.0${stdenv.hostPlatform.extensions.sharedLibrary}"
490
491 substituteInPlace lib/vips.rb \
492 --replace "vips_libname = 'vips'" "vips_libname = '${vips}/lib/libvips${stdenv.hostPlatform.extensions.sharedLibrary}'"
493 '';
494 };
495
496 rugged = attrs: {
497 nativeBuildInputs = [ pkgconfig ];
498 buildInputs = [ which cmake openssl libssh2 zlib ];
499 dontUseCmakeConfigure = true;
500 };
501
502 sassc = attrs: {
503 nativeBuildInputs = [ rake ];
504 dontBuild = false;
505 SASS_LIBSASS_PATH = libsass;
506 postPatch = ''
507 substituteInPlace lib/sassc/native.rb \
508 --replace 'gem_root = spec.gem_dir' 'gem_root = File.join(__dir__, "../../")'
509 '';
510 };
511
512 scrypt = attrs:
513 if stdenv.isDarwin then {
514 dontBuild = false;
515 postPatch = ''
516 sed -i -e "s/-arch i386//" Rakefile ext/scrypt/Rakefile
517 '';
518 } else {};
519
520 semian = attrs: {
521 buildInputs = [ openssl ];
522 };
523
524 sequel_pg = attrs: {
525 buildInputs = [ postgresql ];
526 };
527
528 snappy = attrs: {
529 buildInputs = [ args.snappy ];
530 };
531
532 sqlite3 = attrs: {
533 buildFlags = [
534 "--with-sqlite3-include=${sqlite.dev}/include"
535 "--with-sqlite3-lib=${sqlite.out}/lib"
536 ];
537 };
538
539 rb-readline = attrs: {
540 dontBuild = false;
541 postPatch = ''
542 substituteInPlace lib/rbreadline.rb \
543 --replace 'infocmp' '${ncurses.dev}/bin/infocmp'
544 '';
545 };
546
547 taglib-ruby = attrs: {
548 buildInputs = [ taglib ];
549 };
550
551 thrift = attrs: {
552 # See: https://stackoverflow.com/questions/36378190/cant-install-thrift-gem-on-os-x-el-capitan/36523125#36523125
553 # Note that thrift-0.8.0 is a dependency of fluent-plugin-scribe which is a dependency of fluentd.
554 buildFlags = lib.optional (stdenv.isDarwin && lib.versionOlder attrs.version "0.9.2.0")
555 "--with-cppflags=\"-D_FORTIFY_SOURCE=0 -Wno-macro-redefined -Wno-shift-negative-value\"";
556 };
557
558 timfel-krb5-auth = attrs: {
559 buildInputs = [ kerberos ];
560 };
561
562 tiny_tds = attrs: {
563 nativeBuildInputs = [ pkgconfig openssl ];
564 buildInputs = [ freetds ];
565 };
566
567 therubyracer = attrs: {
568 buildFlags = [
569 "--with-v8-dir=${v8}"
570 "--with-v8-include=${v8}/include"
571 "--with-v8-lib=${v8}/lib"
572 ];
573 };
574
575 typhoeus = attrs: {
576 buildInputs = [ curl ];
577 };
578
579 tzinfo = attrs: lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") {
580 dontBuild = false;
581 postPatch =
582 let
583 path = if lib.versionAtLeast attrs.version "2.0"
584 then "lib/tzinfo/data_sources/zoneinfo_data_source.rb"
585 else "lib/tzinfo/zoneinfo_data_source.rb";
586 in
587 ''
588 substituteInPlace ${path} \
589 --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
590 '';
591 };
592
593 uuid4r = attrs: {
594 buildInputs = [ which libossp_uuid ];
595 };
596
597 xapian-ruby = attrs: {
598 # use the system xapian
599 dontBuild = false;
600 nativeBuildInputs = [ rake pkgconfig bundler ];
601 buildInputs = [ xapian zlib ];
602 postPatch = ''
603 cp ${./xapian-Rakefile} Rakefile
604 '';
605 preInstall = ''
606 export XAPIAN_CONFIG=${xapian}/bin/xapian-config
607 '';
608 };
609
610 zlib = attrs: {
611 buildInputs = [ zlib ];
612 };
613
614 zookeeper = attrs: {
615 buildInputs = stdenv.lib.optionals stdenv.isDarwin [ darwin.cctools ];
616 dontBuild = false;
617 postPatch = ''
618 sed -i ext/extconf.rb -e "4a \
619 FileUtils.cp '${./zookeeper-ftbfs-with-gcc-8.patch}', 'patches/zkc-3.4.5-gcc-8.patch'
620 "
621 '';
622 };
623}