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 separates "what to build" (the exact gem versions) from "how to build"
18# (to make gems behave if necessary).
19
20{ lib, fetchurl, writeScript, ruby, libkrb5, libxml2, libxslt, python2, stdenv, which
21, libiconv, postgresql, v8, clang, sqlite, zlib, imagemagick, lasem
22, pkg-config , ncurses, xapian, gpgme, util-linux, tzdata, icu, libffi
23, cmake, libssh2, openssl, openssl_1_1, libmysqlclient, git, perl, pcre, pcre2, gecode_3, curl
24, msgpack, libsodium, snappy, libossp_uuid, lxc, libpcap, xorg, gtk2, buildRubyGem
25, cairo, expat, 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, dart-sass, libexif, libselinux, libsepol, shared-mime-info, libthai, libdatrie
29, CoreServices, DarwinTools, cctools, libtool, discount, exiv2, libmaxminddb, libyaml
30, autoSignDarwinBinariesHook, fetchpatch
31}@args:
32
33let
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 ZenTest = attrs: {
45 meta.mainProgram = "zentest";
46 };
47
48 atk = attrs: {
49 dependencies = attrs.dependencies ++ [ "gobject-introspection" ];
50 nativeBuildInputs = [ rake bundler pkg-config ]
51 ++ lib.optionals stdenv.isDarwin [ DarwinTools ];
52 propagatedBuildInputs = [ gobject-introspection wrapGAppsHook atk ];
53 };
54
55 bundler = attrs:
56 let
57 templates = "${attrs.ruby.gemPath}/gems/${attrs.gemName}-${attrs.version}/lib/bundler/templates/";
58 in {
59 # patching shebangs would fail on the templates/Executable file, so we
60 # temporarily remove the executable flag.
61 preFixup = "chmod -x $out/${templates}/Executable";
62 postFixup = ''
63 chmod +x $out/${templates}/Executable
64
65 # Allows to load another bundler version
66 sed -i -e "s/activate_bin_path/bin_path/g" $out/bin/bundle
67 '';
68 };
69
70 cairo = attrs: {
71 nativeBuildInputs = [ pkg-config ]
72 ++ lib.optionals stdenv.isDarwin [ DarwinTools ];
73 buildInputs = [ gtk2 pcre2 xorg.libpthreadstubs xorg.libXdmcp];
74 };
75
76 cairo-gobject = attrs: {
77 nativeBuildInputs = [ pkg-config ]
78 ++ lib.optionals stdenv.isDarwin [ DarwinTools ];
79 buildInputs = [ cairo expat pcre2 xorg.libpthreadstubs xorg.libXdmcp ];
80 };
81
82 charlock_holmes = attrs: {
83 buildInputs = [ which icu zlib ];
84 };
85
86 cld3 = attrs: {
87 nativeBuildInputs = [ pkg-config ];
88 buildInputs = [ protobuf ];
89 };
90
91 cocoapods-acknowledgements = attrs: {
92 dependencies = attrs.dependencies ++ [ "cocoapods" ];
93 };
94
95 cocoapods-deploy = attrs: {
96 dependencies = [ "cocoapods" ];
97 };
98
99 cocoapods-disable-podfile-validations = attrs: {
100 dependencies = [ "cocoapods" ];
101 };
102
103 cocoapods-generate = attrs: {
104 dependencies = attrs.dependencies ++ [ "cocoapods" ];
105 };
106
107 cocoapods-git_url_rewriter = attrs: {
108 dependencies = [ "cocoapods" ];
109 };
110
111 cocoapods-keys = attrs: {
112 dependencies = attrs.dependencies ++ [ "cocoapods" ];
113 };
114
115 cocoapods-open = attrs: {
116 dependencies = [ "cocoapods" ];
117 };
118
119 cocoapods-try-release-fix = attrs: {
120 dependencies = [ "cocoapods" ];
121 };
122
123 curb = attrs: {
124 buildInputs = [ curl ];
125 };
126
127 curses = attrs: {
128 buildInputs = [ ncurses ];
129 };
130
131 dep-selector-libgecode = attrs: {
132 USE_SYSTEM_GECODE = true;
133 postInstall = ''
134 installPath=$(cat $out/nix-support/gem-meta/install-path)
135 sed -i $installPath/lib/dep-selector-libgecode.rb -e 's@VENDORED_GECODE_DIR =.*@VENDORED_GECODE_DIR = "${gecode_3}"@'
136 '';
137 };
138
139 digest-sha3 = attrs: {
140 hardeningDisable = [ "format" ];
141 };
142
143 rdiscount = attrs: {
144 # Use discount from nixpkgs instead of vendored version
145 dontBuild = false;
146 buildInputs = [ discount ];
147 patches = [
148 # Adapted from Debian:
149 # https://sources.debian.org/data/main/r/ruby-rdiscount/2.1.8-1/debian/patches/01_use-system-libmarkdown.patch
150 ./rdiscount-use-nixpkgs-libmarkdown.patch
151 ];
152 };
153
154 ethon = attrs: {
155 dontBuild = false;
156 postPatch = ''
157 substituteInPlace lib/ethon/curls/settings.rb \
158 --replace "libcurl" "${curl.out}/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary}"
159 '';
160 };
161
162 exiv2 = attrs: {
163 buildFlags = [ "--with-exiv2-lib=${exiv2}/lib" "--with-exiv2-include=${exiv2.dev}/include" ];
164 };
165
166 fog-dnsimple = attrs:
167 lib.optionalAttrs (lib.versionOlder attrs.version "1.0.1") {
168 postInstall = ''
169 cd $(cat $out/nix-support/gem-meta/install-path)
170 rm {$out/bin,bin,../../bin}/{setup,console}
171 '';
172 };
173
174 redis-rack = attrs: {
175 dontBuild = false;
176 preBuild = ''
177 exec 3>&1
178 output="$(gem build $gemspec | tee >(cat - >&3))"
179 exec 3>&-
180 sed -i 's!"rake".freeze!!' $gemspec
181 '';
182 };
183
184 ffi-rzmq-core = attrs: {
185 postInstall = ''
186 installPath=$(cat $out/nix-support/gem-meta/install-path)
187 sed -i $installPath/lib/ffi-rzmq-core/libzmq.rb -e 's@inside_gem =.*@inside_gem = "${zeromq}/lib"@'
188 '';
189 };
190
191 mimemagic = attrs: {
192 FREEDESKTOP_MIME_TYPES_PATH = "${shared-mime-info}/share/mime/packages/freedesktop.org.xml";
193 };
194
195 mini_magick = attrs: {
196 postInstall = ''
197 installPath=$(cat $out/nix-support/gem-meta/install-path)
198 echo -e "\nENV['PATH'] += ':${graphicsmagick}/bin'\n" >> $installPath/lib/mini_magick/configuration.rb
199 '';
200 };
201
202 do_sqlite3 = attrs: {
203 buildInputs = [ sqlite ];
204 };
205
206 eventmachine = attrs: {
207 dontBuild = false;
208 buildInputs = [ openssl ];
209 postPatch = ''
210 substituteInPlace ext/em.cpp \
211 --replace 'if (bind (' 'if (::bind ('
212 '';
213 };
214
215 exif = attrs: {
216 buildFlags = [ "--with-exif-dir=${libexif}" ];
217 buildInputs = [ libexif ];
218 };
219
220 ffi = attrs: {
221 nativeBuildInputs = [ pkg-config ];
222 buildInputs = [ libffi ];
223 };
224
225 fiddle = attrs: {
226 buildInputs = [ libffi ];
227 };
228
229 gdk_pixbuf2 = attrs: {
230 nativeBuildInputs = [ pkg-config bundler rake ]
231 ++ lib.optionals stdenv.isDarwin [ DarwinTools ];
232 propagatedBuildInputs = [ gobject-introspection wrapGAppsHook gdk-pixbuf ];
233 };
234
235 gpgme = attrs: {
236 buildInputs = [ gpgme ];
237 nativeBuildInputs = [ pkg-config ];
238 buildFlags = [ "--use-system-libraries" ];
239 };
240
241 gio2 = attrs: {
242 nativeBuildInputs = [ pkg-config gobject-introspection ]
243 ++ lib.optionals stdenv.isDarwin [ DarwinTools ];
244 buildInputs = [ gtk2 pcre pcre2 ] ++ lib.optionals stdenv.isLinux [ util-linux libselinux libsepol ];
245 };
246
247 gitlab-markup = attrs: { meta.priority = 1; };
248
249 gitlab-pg_query = attrs: lib.optionalAttrs (attrs.version == "1.3.1") {
250 dontBuild = false;
251 postPatch = ''
252 sed -i "s;'https://codeload.github.com.*';'${fetchurl {
253 url = "https://codeload.github.com/lfittl/libpg_query/tar.gz/10-1.0.3";
254 sha256 = "0jfij8apzxsdabl70j42xgd5f3ka1gdcrk764nccp66164gpcchk";
255 }}';" ext/pg_query/extconf.rb
256 '';
257 };
258
259 parser = attrs: {
260 meta.mainProgram = "ruby-parse";
261 };
262
263 pg_query = attrs: lib.optionalAttrs (attrs.version == "2.0.2") {
264 dontBuild = false;
265 postPatch = ''
266 sed -i "s;'https://codeload.github.com.*';'${fetchurl {
267 url = "https://codeload.github.com/lfittl/libpg_query/tar.gz/13-2.0.2";
268 sha256 = "0ms2s6hmy8qyzv4g1hj4i2p5fws1v8lrj73b2knwbp2ipd45yj7y";
269 }}';" ext/pg_query/extconf.rb
270 '';
271 } // lib.optionalAttrs (attrs.version == "1.3.0") {
272 # Needed for gitlab
273 dontBuild = false;
274 postPatch = ''
275 sed -i "s;'https://codeload.github.com.*';'${fetchurl {
276 url = "https://codeload.github.com/lfittl/libpg_query/tar.gz/10-1.0.4";
277 sha256 = "0f0kshhai0pnkqj0w4kgz3fssnvwidllc31n1fysxjjzdqlr1k48";
278 }}';" ext/pg_query/extconf.rb
279 '';
280 };
281
282 prettier = attrs: {
283 meta.mainProgram = "rbprettier";
284 };
285
286 prometheus-client-mmap = attrs: {
287 dontBuild = false;
288 postPatch = let
289 getconf = if stdenv.hostPlatform.isGnu then stdenv.cc.libc else getconf;
290 in ''
291 substituteInPlace lib/prometheus/client/page_size.rb --replace "getconf" "${lib.getBin getconf}/bin/getconf"
292 '';
293 };
294
295 glib2 = attrs: {
296 nativeBuildInputs = [ pkg-config ]
297 ++ lib.optionals stdenv.isDarwin [ DarwinTools ];
298 buildInputs = [ gtk2 pcre2 ];
299 };
300
301 gtk2 = attrs: {
302 nativeBuildInputs = [
303 binutils pkg-config
304 ] ++ lib.optionals stdenv.isLinux [
305 util-linux libselinux libsepol
306 ] ++ lib.optionals stdenv.isDarwin [ DarwinTools ];
307 propagatedBuildInputs = [
308 atk
309 gdk-pixbuf
310 fribidi
311 gobject-introspection
312 gtk2
313 harfbuzz
314 libdatrie
315 libthai
316 pcre pcre2
317 xorg.libpthreadstubs
318 xorg.libXdmcp
319 ];
320 dontStrip = stdenv.isDarwin;
321 };
322
323 gobject-introspection = attrs: {
324 nativeBuildInputs = [ pkg-config pcre2 ]
325 ++ lib.optionals stdenv.isDarwin [ DarwinTools ];
326 propagatedBuildInputs = [ gobject-introspection wrapGAppsHook glib ];
327 };
328
329 gollum = attrs: {
330 dontBuild = false;
331 postPatch = ''
332 substituteInPlace bin/gollum \
333 --replace "/usr/bin/env -S ruby" "${ruby}/bin/ruby"
334 '';
335 };
336
337 google-protobuf = attrs:
338 lib.optionalAttrs (lib.versionAtLeast attrs.version "3.25.0") {
339 # Fails on 3.25.0 with:
340 # convert.c:312:32: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
341 hardeningDisable = [ "format" ];
342 };
343
344 grpc = attrs: {
345 nativeBuildInputs = [ pkg-config ]
346 ++ lib.optional stdenv.isDarwin cctools
347 ++ lib.optional (lib.versionAtLeast attrs.version "1.53.0" && stdenv.isDarwin && stdenv.isAarch64) autoSignDarwinBinariesHook;
348 buildInputs = [ openssl ];
349 hardeningDisable = [ "format" ];
350 env.NIX_CFLAGS_COMPILE = toString [
351 "-Wno-error=stringop-overflow"
352 "-Wno-error=implicit-fallthrough"
353 "-Wno-error=sizeof-pointer-memaccess"
354 "-Wno-error=cast-function-type"
355 "-Wno-error=class-memaccess"
356 "-Wno-error=ignored-qualifiers"
357 "-Wno-error=tautological-compare"
358 "-Wno-error=stringop-truncation"
359 ];
360 dontBuild = false;
361 postPatch = ''
362 substituteInPlace Makefile \
363 --replace '-Wno-invalid-source-encoding' ""
364 '' + lib.optionalString (lib.versionOlder attrs.version "1.53.0" && stdenv.isDarwin) ''
365 # For < v1.48.0
366 substituteInPlace src/ruby/ext/grpc/extconf.rb \
367 --replace "ENV['AR'] = 'libtool -o' if RUBY_PLATFORM =~ /darwin/" ""
368 # For >= v1.48.0
369 substituteInPlace src/ruby/ext/grpc/extconf.rb \
370 --replace 'apple_toolchain = ' 'apple_toolchain = false && '
371 '';
372 };
373
374 hitimes = attrs: {
375 buildInputs = lib.optionals stdenv.isDarwin [ CoreServices ];
376 };
377
378 iconv = attrs: {
379 dontBuild = false;
380 buildFlags = lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
381 patches = [
382 # Fix incompatible function pointer conversion errors with clang 16
383 ./iconv-fix-incompatible-function-pointer-conversions.patch
384 ];
385 };
386
387 idn-ruby = attrs: {
388 buildInputs = [ libidn ];
389 };
390
391 # disable bundle install as it can't install anything in addition to what is
392 # specified in pkgs/applications/misc/jekyll/Gemfile anyway. Also do chmod_R
393 # to compensate for read-only files in site_template in nix store.
394 jekyll = attrs: {
395 postInstall = ''
396 installPath=$(cat $out/nix-support/gem-meta/install-path)
397 sed -i $installPath/lib/jekyll/commands/new.rb \
398 -e 's@Exec.run("bundle", "install"@Exec.run("true"@' \
399 -e 's@FileUtils.cp_r site_template + "/.", path@FileUtils.cp_r site_template + "/.", path; FileUtils.chmod_R "u+w", path@'
400 '';
401 };
402
403 # note that you need version >= v3.16.14.8,
404 # otherwise the gem will fail to link to the libv8 binary.
405 # see: https://github.com/cowboyd/libv8/pull/161
406 libv8 = attrs: {
407 buildInputs = [ which v8 python2 ];
408 buildFlags = [ "--with-system-v8=true" ];
409 dontBuild = false;
410 # The gem includes broken symlinks which are ignored during unpacking, but
411 # then fail during build. Since the content is missing anyway, touching the
412 # files is enough to unblock the build.
413 preBuild = ''
414 touch vendor/depot_tools/cbuildbot vendor/depot_tools/chrome_set_ver vendor/depot_tools/cros_sdk
415 '';
416 postPatch = ''
417 substituteInPlace ext/libv8/extconf.rb \
418 --replace "location = Libv8::Location::Vendor.new" \
419 "location = Libv8::Location::System.new"
420 '';
421 meta.broken = true; # At 2023-01-20, errors as:
422 # "Failed to build gem native extension."
423 # Requires Python 2. Project is abandoned.
424 };
425
426 execjs = attrs: {
427 propagatedBuildInputs = [ v8 ];
428 };
429
430 libxml-ruby = attrs: {
431 buildFlags = [
432 "--with-xml2-lib=${libxml2.out}/lib"
433 "--with-xml2-include=${libxml2.dev}/include/libxml2"
434 ] ++ lib.optionals stdenv.isDarwin [
435 "--with-iconv-dir=${libiconv}"
436 "--with-opt-include=${libiconv}/include"
437 ];
438 };
439
440 mathematical = attrs: {
441 nativeBuildInputs = [
442 ruby
443 cmake
444 bison
445 flex
446 pkg-config
447 python3
448 patchelf
449 ];
450
451 buildInputs = [
452 cairo
453 fribidi
454 gdk-pixbuf
455 glib
456 libxml2
457 pango
458 ];
459
460 strictDeps = true;
461
462 # The ruby build script takes care of this
463 dontUseCmakeConfigure = true;
464
465 postInstall = ''
466 # Reduce output size by a lot, and remove some unnecessary references.
467 # The ext directory should only be required at build time, so
468 # can be deleted now.
469 rm -r $out/${ruby.gemPath}/gems/mathematical-${attrs.version}/ext \
470 $out/${ruby.gemPath}/extensions/*/*/mathematical-${attrs.version}/gem_make.out
471 '';
472
473 # For some reason 'mathematical.so' is missing cairo, glib, and
474 # lasem in its RPATH, add them explicitly here
475 postFixup = lib.optionalString stdenv.isLinux ''
476 soPath="$out/${ruby.gemPath}/gems/mathematical-${attrs.version}/lib/mathematical/mathematical.so"
477 rpath="$(patchelf --print-rpath "$soPath")"
478 patchelf --set-rpath "${lib.makeLibraryPath [ lasem glib cairo ]}:$rpath" "$soPath"
479 patchelf --replace-needed liblasem.so liblasem-0.4.so "$soPath"
480 '';
481 };
482
483 magic = attrs: {
484 buildInputs = [ file ];
485 postInstall = ''
486 installPath=$(cat $out/nix-support/gem-meta/install-path)
487 sed -e 's@ENV\["MAGIC_LIB"\] ||@ENV\["MAGIC_LIB"\] || "${file}/lib/libmagic.so" ||@' -i $installPath/lib/magic/api.rb
488 '';
489 };
490
491 maxmind_geoip2 = attrs: {
492 buildFlags = [ "--with-maxminddb-lib=${libmaxminddb}/lib" "--with-maxminddb-include=${libmaxminddb}/include" ];
493 };
494
495 metasploit-framework = attrs: {
496 preInstall = ''
497 export HOME=$TMPDIR
498 '';
499 };
500
501 msgpack = attrs: {
502 buildInputs = [ msgpack ];
503 };
504
505 mysql = attrs: {
506 buildInputs = [ libmysqlclient zlib openssl ];
507 };
508
509 mysql2 = attrs: {
510 buildInputs = [ libmysqlclient zlib openssl ];
511 };
512
513 ncursesw = attrs: {
514 buildInputs = [ ncurses ];
515 buildFlags = [
516 "--with-cflags=-I${ncurses.dev}/include"
517 "--with-ldflags=-L${ncurses.out}/lib"
518 ];
519 };
520
521 nokogiri = attrs: {
522 buildFlags = [
523 "--use-system-libraries"
524 "--with-zlib-lib=${zlib.out}/lib"
525 "--with-zlib-include=${zlib.dev}/include"
526 "--with-xml2-lib=${libxml2.out}/lib"
527 "--with-xml2-include=${libxml2.dev}/include/libxml2"
528 "--with-xslt-lib=${libxslt.out}/lib"
529 "--with-xslt-include=${libxslt.dev}/include"
530 "--with-exslt-lib=${libxslt.out}/lib"
531 "--with-exslt-include=${libxslt.dev}/include"
532 ] ++ lib.optionals stdenv.isDarwin [
533 "--with-iconv-dir=${libiconv}"
534 "--with-opt-include=${libiconv}/include"
535 ];
536 };
537
538 openssl = attrs: {
539 # https://github.com/ruby/openssl/issues/369
540 buildInputs = [ (if (lib.versionAtLeast attrs.version "3.0.0") then openssl else openssl_1_1) ];
541 };
542
543 opus-ruby = attrs: {
544 dontBuild = false;
545 postPatch = ''
546 substituteInPlace lib/opus-ruby.rb \
547 --replace "ffi_lib 'opus'" \
548 "ffi_lib '${libopus}/lib/libopus${stdenv.hostPlatform.extensions.sharedLibrary}'"
549 '';
550 };
551
552 ovirt-engine-sdk = attrs: {
553 buildInputs = [ curl libxml2 ];
554 dontBuild = false;
555 patches = [
556 # fix ruby 3.1 https://github.com/oVirt/ovirt-engine-sdk-ruby/pull/3
557 (fetchpatch {
558 url = "https://github.com/oVirt/ovirt-engine-sdk-ruby/pull/3/commits/b596b919bc7857fdc0fc1c61a8cb7eab32cfc2db.patch";
559 hash = "sha256-AzGTQaD/e6X4LOMuXhy/WhbayhWKYCGHXPFlzLRWyPM=";
560 stripLen = 1;
561 })
562 ];
563 };
564
565 pango = attrs: {
566 nativeBuildInputs = [
567 pkg-config
568 fribidi
569 harfbuzz
570 pcre pcre2
571 xorg.libpthreadstubs
572 xorg.libXdmcp
573 ] ++ lib.optionals stdenv.isDarwin [ DarwinTools ];
574 buildInputs = [ libdatrie libthai ]
575 ++ lib.optionals stdenv.isLinux [ libselinux libsepol util-linux ];
576 propagatedBuildInputs = [ gobject-introspection wrapGAppsHook gtk2 ];
577 };
578
579 patron = attrs: {
580 buildInputs = [ curl ];
581 };
582
583 pcaprub = attrs: {
584 buildInputs = [ libpcap ];
585 };
586
587 pg = attrs: {
588 # Force pkg-config lookup for libpq.
589 # See https://github.com/ged/ruby-pg/blob/6629dec6656f7ca27619e4675b45225d9e422112/ext/extconf.rb#L34-L55
590 #
591 # Note that setting --with-pg-config=${postgresql}/bin/pg_config would add
592 # an unnecessary reference to the entire postgresql package.
593 buildFlags = [ "--with-pg-config=ignore" ];
594 nativeBuildInputs = [ pkg-config ];
595 buildInputs = [ postgresql ];
596 };
597
598 psych = attrs: {
599 buildInputs = [ libyaml ];
600 };
601
602 puma = attrs: {
603 buildInputs = [ openssl ];
604 };
605
606 "pygments.rb" = attrs: {
607 buildInputs = [ python3 ];
608 };
609
610 rack = attrs: {
611 meta.mainProgram = "rackup";
612 };
613
614 railties = attrs: {
615 meta.mainProgram = "rails";
616 };
617
618 rainbow = attrs: {
619 buildInputs = [ rainbow_rake ];
620 };
621
622 rbczmq = { ... }: {
623 buildInputs = [ zeromq czmq ];
624 buildFlags = [ "--with-system-libs" ];
625 };
626
627 rbnacl = spec:
628 if lib.versionOlder spec.version "6.0.0" then {
629 postInstall = ''
630 sed -i $(cat $out/nix-support/gem-meta/install-path)/lib/rbnacl.rb -e "2a \
631 RBNACL_LIBSODIUM_GEM_LIB_PATH = '${libsodium.out}/lib/libsodium${stdenv.hostPlatform.extensions.sharedLibrary}'
632 "
633 '';
634 } else {
635 dontBuild = false;
636 postPatch = ''
637 substituteInPlace lib/rbnacl/sodium.rb \
638 --replace 'ffi_lib ["sodium"' \
639 'ffi_lib ["${libsodium}/lib/libsodium${stdenv.hostPlatform.extensions.sharedLibrary}"'
640 '';
641 };
642
643 re2 = attrs: {
644 buildInputs = [ re2 ];
645 buildFlags = [
646 "--enable-system-libraries"
647 ];
648 };
649
650 rest-client = attrs: {
651 meta.mainProgram = "restclient";
652 };
653
654 rmagick = attrs: {
655 nativeBuildInputs = [ pkg-config ];
656 buildInputs = [ imagemagick which ];
657 };
658
659 rouge = attrs: {
660 meta.mainProgram = "rougify";
661 };
662
663 rpam2 = attrs: {
664 buildInputs = [ linux-pam ];
665 };
666
667 rspec-core = attrs: {
668 meta.mainProgram = "rspec";
669 };
670
671 ruby-libvirt = attrs: {
672 nativeBuildInputs = [ pkg-config ];
673 buildInputs = [ libvirt ];
674 buildFlags = [
675 "--with-libvirt-include=${libvirt}/include"
676 "--with-libvirt-lib=${libvirt}/lib"
677 ];
678 };
679
680 ruby-lxc = attrs: {
681 buildInputs = [ lxc ];
682 };
683
684 ruby-terminfo = attrs: {
685 buildInputs = [ ncurses ];
686 buildFlags = [
687 "--with-cflags=-I${ncurses.dev}/include"
688 "--with-ldflags=-L${ncurses.out}/lib"
689 ];
690 dontBuild = false;
691 postPatch = ''
692 substituteInPlace extconf.rb --replace 'rubyio.h' 'ruby/io.h'
693 substituteInPlace terminfo.c \
694 --replace 'rubyio.h' 'ruby/io.h' \
695 --replace 'rb_cData' 'rb_cObject'
696 '';
697 };
698
699 ruby-vips = attrs: {
700 postInstall = ''
701 cd "$(cat $out/nix-support/gem-meta/install-path)"
702
703 substituteInPlace lib/vips.rb \
704 --replace 'library_name("vips", 42)' '"${lib.getLib vips}/lib/libvips${stdenv.hostPlatform.extensions.sharedLibrary}"' \
705 --replace 'library_name("glib-2.0", 0)' '"${glib.out}/lib/libglib-2.0${stdenv.hostPlatform.extensions.sharedLibrary}"' \
706 --replace 'library_name("gobject-2.0", 0)' '"${glib.out}/lib/libgobject-2.0${stdenv.hostPlatform.extensions.sharedLibrary}"'
707 '';
708 };
709
710 rugged = attrs: {
711 nativeBuildInputs = [ cmake pkg-config which ] ++ lib.optional stdenv.isDarwin libiconv;
712 buildInputs = [ openssl libssh2 zlib ];
713 dontUseCmakeConfigure = true;
714 };
715
716 sassc = attrs: {
717 nativeBuildInputs = [ rake ];
718 dontBuild = false;
719 SASS_LIBSASS_PATH = toString libsass;
720 postPatch = ''
721 substituteInPlace lib/sassc/native.rb \
722 --replace 'gem_root = spec.gem_dir' 'gem_root = File.join(__dir__, "../../")'
723 '';
724 } // (lib.optionalAttrs stdenv.isDarwin {
725 # https://github.com/NixOS/nixpkgs/issues/19098
726 buildFlags = [ "--disable-lto" ];
727 });
728
729 sass-embedded = attrs: {
730 # Patch the Rakefile to use our dart-sass and not try to fetch anything.
731 dontBuild = false;
732 postPatch = ''
733 substituteInPlace ext/sass/Rakefile \
734 --replace \'dart-sass/sass\' \'${dart-sass}/bin/sass\' \
735 --replace ' => %w[dart-sass]' ""
736 '';
737 };
738
739 scrypt = attrs: lib.optionalAttrs stdenv.isDarwin {
740 dontBuild = false;
741 postPatch = ''
742 sed -i -e "s/-arch i386//" Rakefile ext/scrypt/Rakefile
743 '';
744 };
745
746 semian = attrs: {
747 buildInputs = [ openssl ];
748 };
749
750 sequel_pg = attrs: {
751 buildInputs = [ postgresql ];
752 };
753
754 snappy = attrs: {
755 buildInputs = [ args.snappy ];
756 };
757
758 sqlite3 = attrs: if lib.versionAtLeast attrs.version "1.5.0"
759 then {
760 nativeBuildInputs = [ pkg-config ];
761 buildInputs = [ sqlite ];
762 buildFlags = [
763 "--enable-system-libraries"
764 ];
765 }
766 else {
767 buildFlags = [
768 "--with-sqlite3-include=${sqlite.dev}/include"
769 "--with-sqlite3-lib=${sqlite.out}/lib"
770 ];
771 };
772
773 rb-readline = attrs: {
774 dontBuild = false;
775 postPatch = ''
776 substituteInPlace lib/rbreadline.rb \
777 --replace 'infocmp' '${ncurses}/bin/infocmp'
778 '';
779 };
780
781 taglib-ruby = attrs: {
782 buildInputs = [ taglib ];
783 };
784
785 timfel-krb5-auth = attrs: {
786 buildInputs = [ libkrb5 ];
787 };
788
789 tiny_tds = attrs: {
790 nativeBuildInputs = [ pkg-config openssl ];
791 buildInputs = [ freetds ];
792 };
793
794 treetop = attrs: {
795 meta.mainProgram = "tt";
796 };
797
798 typhoeus = attrs: {
799 buildInputs = [ curl ];
800 };
801
802 tzinfo = attrs: lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") {
803 dontBuild = false;
804 postPatch =
805 let
806 path = if lib.versionAtLeast attrs.version "2.0"
807 then "lib/tzinfo/data_sources/zoneinfo_data_source.rb"
808 else "lib/tzinfo/zoneinfo_data_source.rb";
809 in
810 ''
811 substituteInPlace ${path} \
812 --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
813 '';
814 };
815
816 uuid4r = attrs: {
817 buildInputs = [ which libossp_uuid ];
818 };
819
820 whois = attrs: {
821 meta.mainProgram = "whoisrb";
822 };
823
824 xapian-ruby = attrs: {
825 # use the system xapian
826 dontBuild = false;
827 nativeBuildInputs = [ rake pkg-config bundler ];
828 buildInputs = [ xapian zlib ];
829 postPatch = ''
830 cp ${./xapian-Rakefile} Rakefile
831 '';
832 preInstall = ''
833 export XAPIAN_CONFIG=${xapian}/bin/xapian-config
834 '';
835 };
836
837 zlib = attrs: {
838 buildInputs = [ zlib ];
839 };
840
841 zookeeper = attrs: {
842 buildInputs = lib.optionals stdenv.isDarwin [ cctools ];
843 };
844}