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