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, 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, 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 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 ]
243 ++ lib.optionals stdenv.isDarwin [ DarwinTools ];
244 buildInputs = [ gtk2 pcre pcre2 gobject-introspection ] ++ 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 grpc = attrs: {
338 nativeBuildInputs = [ pkg-config ]
339 ++ lib.optional stdenv.isDarwin cctools
340 ++ lib.optional (lib.versionAtLeast attrs.version "1.53.0" && stdenv.isDarwin && stdenv.isAarch64) autoSignDarwinBinariesHook;
341 buildInputs = [ openssl ];
342 hardeningDisable = [ "format" ];
343 env.NIX_CFLAGS_COMPILE = toString [
344 "-Wno-error=stringop-overflow"
345 "-Wno-error=implicit-fallthrough"
346 "-Wno-error=sizeof-pointer-memaccess"
347 "-Wno-error=cast-function-type"
348 "-Wno-error=class-memaccess"
349 "-Wno-error=ignored-qualifiers"
350 "-Wno-error=tautological-compare"
351 "-Wno-error=stringop-truncation"
352 ];
353 dontBuild = false;
354 postPatch = ''
355 substituteInPlace Makefile \
356 --replace '-Wno-invalid-source-encoding' ""
357 '' + lib.optionalString (lib.versionOlder attrs.version "1.53.0" && stdenv.isDarwin) ''
358 # For < v1.48.0
359 substituteInPlace src/ruby/ext/grpc/extconf.rb \
360 --replace "ENV['AR'] = 'libtool -o' if RUBY_PLATFORM =~ /darwin/" ""
361 # For >= v1.48.0
362 substituteInPlace src/ruby/ext/grpc/extconf.rb \
363 --replace 'apple_toolchain = ' 'apple_toolchain = false && '
364 '';
365 };
366
367 hitimes = attrs: {
368 buildInputs = lib.optionals stdenv.isDarwin [ CoreServices ];
369 };
370
371 iconv = attrs: {
372 buildFlags = lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
373 };
374
375 idn-ruby = attrs: {
376 buildInputs = [ libidn ];
377 };
378
379 # disable bundle install as it can't install anything in addition to what is
380 # specified in pkgs/applications/misc/jekyll/Gemfile anyway. Also do chmod_R
381 # to compensate for read-only files in site_template in nix store.
382 jekyll = attrs: {
383 postInstall = ''
384 installPath=$(cat $out/nix-support/gem-meta/install-path)
385 sed -i $installPath/lib/jekyll/commands/new.rb \
386 -e 's@Exec.run("bundle", "install"@Exec.run("true"@' \
387 -e 's@FileUtils.cp_r site_template + "/.", path@FileUtils.cp_r site_template + "/.", path; FileUtils.chmod_R "u+w", path@'
388 '';
389 };
390
391 # note that you need version >= v3.16.14.8,
392 # otherwise the gem will fail to link to the libv8 binary.
393 # see: https://github.com/cowboyd/libv8/pull/161
394 libv8 = attrs: {
395 buildInputs = [ which v8 python2 ];
396 buildFlags = [ "--with-system-v8=true" ];
397 dontBuild = false;
398 # The gem includes broken symlinks which are ignored during unpacking, but
399 # then fail during build. Since the content is missing anyway, touching the
400 # files is enough to unblock the build.
401 preBuild = ''
402 touch vendor/depot_tools/cbuildbot vendor/depot_tools/chrome_set_ver vendor/depot_tools/cros_sdk
403 '';
404 postPatch = ''
405 substituteInPlace ext/libv8/extconf.rb \
406 --replace "location = Libv8::Location::Vendor.new" \
407 "location = Libv8::Location::System.new"
408 '';
409 meta.broken = true; # At 2023-01-20, errors as:
410 # "Failed to build gem native extension."
411 # Requires Python 2. Project is abandoned.
412 };
413
414 execjs = attrs: {
415 propagatedBuildInputs = [ v8 ];
416 };
417
418 libxml-ruby = attrs: {
419 buildFlags = [
420 "--with-xml2-lib=${libxml2.out}/lib"
421 "--with-xml2-include=${libxml2.dev}/include/libxml2"
422 ] ++ lib.optionals stdenv.isDarwin [
423 "--with-iconv-dir=${libiconv}"
424 "--with-opt-include=${libiconv}/include"
425 ];
426 };
427
428 mathematical = attrs: {
429 nativeBuildInputs = [
430 ruby
431 cmake
432 bison
433 flex
434 pkg-config
435 python3
436 patchelf
437 ];
438
439 buildInputs = [
440 cairo
441 fribidi
442 gdk-pixbuf
443 glib
444 libxml2
445 pango
446 ];
447
448 strictDeps = true;
449
450 # The ruby build script takes care of this
451 dontUseCmakeConfigure = true;
452
453 postInstall = ''
454 # Reduce output size by a lot, and remove some unnecessary references.
455 # The ext directory should only be required at build time, so
456 # can be deleted now.
457 rm -r $out/${ruby.gemPath}/gems/mathematical-${attrs.version}/ext \
458 $out/${ruby.gemPath}/extensions/*/*/mathematical-${attrs.version}/gem_make.out
459 '';
460
461 # For some reason 'mathematical.so' is missing cairo, glib, and
462 # lasem in its RPATH, add them explicitly here
463 postFixup = lib.optionalString stdenv.isLinux ''
464 soPath="$out/${ruby.gemPath}/gems/mathematical-${attrs.version}/lib/mathematical/mathematical.so"
465 rpath="$(patchelf --print-rpath "$soPath")"
466 patchelf --set-rpath "${lib.makeLibraryPath [ lasem glib cairo ]}:$rpath" "$soPath"
467 patchelf --replace-needed liblasem.so liblasem-0.4.so "$soPath"
468 '';
469 };
470
471 magic = attrs: {
472 buildInputs = [ file ];
473 postInstall = ''
474 installPath=$(cat $out/nix-support/gem-meta/install-path)
475 sed -e 's@ENV\["MAGIC_LIB"\] ||@ENV\["MAGIC_LIB"\] || "${file}/lib/libmagic.so" ||@' -i $installPath/lib/magic/api.rb
476 '';
477 };
478
479 maxmind_geoip2 = attrs: {
480 buildFlags = [ "--with-maxminddb-lib=${libmaxminddb}/lib" "--with-maxminddb-include=${libmaxminddb}/include" ];
481 };
482
483 metasploit-framework = attrs: {
484 preInstall = ''
485 export HOME=$TMPDIR
486 '';
487 };
488
489 msgpack = attrs: {
490 buildInputs = [ msgpack ];
491 };
492
493 mysql = attrs: {
494 buildInputs = [ libmysqlclient zlib openssl ];
495 };
496
497 mysql2 = attrs: {
498 buildInputs = [ libmysqlclient zlib openssl ];
499 };
500
501 ncursesw = attrs: {
502 buildInputs = [ ncurses ];
503 buildFlags = [
504 "--with-cflags=-I${ncurses.dev}/include"
505 "--with-ldflags=-L${ncurses.out}/lib"
506 ];
507 };
508
509 nokogiri = attrs: {
510 buildFlags = [
511 "--use-system-libraries"
512 "--with-zlib-lib=${zlib.out}/lib"
513 "--with-zlib-include=${zlib.dev}/include"
514 "--with-xml2-lib=${libxml2.out}/lib"
515 "--with-xml2-include=${libxml2.dev}/include/libxml2"
516 "--with-xslt-lib=${libxslt.out}/lib"
517 "--with-xslt-include=${libxslt.dev}/include"
518 "--with-exslt-lib=${libxslt.out}/lib"
519 "--with-exslt-include=${libxslt.dev}/include"
520 ] ++ lib.optionals stdenv.isDarwin [
521 "--with-iconv-dir=${libiconv}"
522 "--with-opt-include=${libiconv}/include"
523 ];
524 };
525
526 openssl = attrs: {
527 # https://github.com/ruby/openssl/issues/369
528 buildInputs = [ (if (lib.versionAtLeast attrs.version "3.0.0") then openssl else openssl_1_1) ];
529 };
530
531 opus-ruby = attrs: {
532 dontBuild = false;
533 postPatch = ''
534 substituteInPlace lib/opus-ruby.rb \
535 --replace "ffi_lib 'opus'" \
536 "ffi_lib '${libopus}/lib/libopus${stdenv.hostPlatform.extensions.sharedLibrary}'"
537 '';
538 };
539
540 ovirt-engine-sdk = attrs: {
541 buildInputs = [ curl libxml2 ];
542 dontBuild = false;
543 patches = [
544 # fix ruby 3.1 https://github.com/oVirt/ovirt-engine-sdk-ruby/pull/3
545 (fetchpatch {
546 url = "https://github.com/oVirt/ovirt-engine-sdk-ruby/pull/3/commits/b596b919bc7857fdc0fc1c61a8cb7eab32cfc2db.patch";
547 hash = "sha256-AzGTQaD/e6X4LOMuXhy/WhbayhWKYCGHXPFlzLRWyPM=";
548 stripLen = 1;
549 })
550 ];
551 };
552
553 pango = attrs: {
554 nativeBuildInputs = [
555 pkg-config
556 fribidi
557 harfbuzz
558 pcre pcre2
559 xorg.libpthreadstubs
560 xorg.libXdmcp
561 ] ++ lib.optionals stdenv.isDarwin [ DarwinTools ];
562 buildInputs = [ libdatrie libthai ]
563 ++ lib.optionals stdenv.isLinux [ libselinux libsepol util-linux ];
564 propagatedBuildInputs = [ gobject-introspection wrapGAppsHook gtk2 ];
565 };
566
567 patron = attrs: {
568 buildInputs = [ curl ];
569 };
570
571 pcaprub = attrs: {
572 buildInputs = [ libpcap ];
573 };
574
575 pg = attrs: {
576 buildFlags = [
577 "--with-pg-config=${postgresql}/bin/pg_config"
578 ];
579 };
580
581 psych = attrs: {
582 buildInputs = [ libyaml ];
583 };
584
585 puma = attrs: {
586 buildInputs = [ openssl ];
587 };
588
589 "pygments.rb" = attrs: {
590 buildInputs = [ python3 ];
591 };
592
593 rack = attrs: {
594 meta.mainProgram = "rackup";
595 };
596
597 railties = attrs: {
598 meta.mainProgram = "rails";
599 };
600
601 rainbow = attrs: {
602 buildInputs = [ rainbow_rake ];
603 };
604
605 rbczmq = { ... }: {
606 buildInputs = [ zeromq czmq ];
607 buildFlags = [ "--with-system-libs" ];
608 };
609
610 rbnacl = spec:
611 if lib.versionOlder spec.version "6.0.0" then {
612 postInstall = ''
613 sed -i $(cat $out/nix-support/gem-meta/install-path)/lib/rbnacl.rb -e "2a \
614 RBNACL_LIBSODIUM_GEM_LIB_PATH = '${libsodium.out}/lib/libsodium${stdenv.hostPlatform.extensions.sharedLibrary}'
615 "
616 '';
617 } else {
618 dontBuild = false;
619 postPatch = ''
620 substituteInPlace lib/rbnacl/sodium.rb \
621 --replace 'ffi_lib ["sodium"' \
622 'ffi_lib ["${libsodium}/lib/libsodium${stdenv.hostPlatform.extensions.sharedLibrary}"'
623 '';
624 };
625
626 re2 = attrs: {
627 buildInputs = [ re2 ];
628 };
629
630 rest-client = attrs: {
631 meta.mainProgram = "restclient";
632 };
633
634 rmagick = attrs: {
635 nativeBuildInputs = [ pkg-config ];
636 buildInputs = [ imagemagick which ];
637 };
638
639 rouge = attrs: {
640 meta.mainProgram = "rougify";
641 };
642
643 rpam2 = attrs: {
644 buildInputs = [ linux-pam ];
645 };
646
647 rspec-core = attrs: {
648 meta.mainProgram = "rspec";
649 };
650
651 ruby-libvirt = attrs: {
652 nativeBuildInputs = [ pkg-config ];
653 buildInputs = [ libvirt ];
654 buildFlags = [
655 "--with-libvirt-include=${libvirt}/include"
656 "--with-libvirt-lib=${libvirt}/lib"
657 ];
658 };
659
660 ruby-lxc = attrs: {
661 buildInputs = [ lxc ];
662 };
663
664 ruby-terminfo = attrs: {
665 buildInputs = [ ncurses ];
666 buildFlags = [
667 "--with-cflags=-I${ncurses.dev}/include"
668 "--with-ldflags=-L${ncurses.out}/lib"
669 ];
670 dontBuild = false;
671 postPatch = ''
672 substituteInPlace extconf.rb --replace 'rubyio.h' 'ruby/io.h'
673 substituteInPlace terminfo.c \
674 --replace 'rubyio.h' 'ruby/io.h' \
675 --replace 'rb_cData' 'rb_cObject'
676 '';
677 };
678
679 ruby-vips = attrs: {
680 postInstall = ''
681 cd "$(cat $out/nix-support/gem-meta/install-path)"
682
683 substituteInPlace lib/vips.rb \
684 --replace 'library_name("vips", 42)' '"${lib.getLib vips}/lib/libvips${stdenv.hostPlatform.extensions.sharedLibrary}"' \
685 --replace 'library_name("glib-2.0", 0)' '"${glib.out}/lib/libglib-2.0${stdenv.hostPlatform.extensions.sharedLibrary}"' \
686 --replace 'library_name("gobject-2.0", 0)' '"${glib.out}/lib/libgobject-2.0${stdenv.hostPlatform.extensions.sharedLibrary}"'
687 '';
688 };
689
690 rugged = attrs: {
691 nativeBuildInputs = [ cmake pkg-config which ] ++ lib.optional stdenv.isDarwin libiconv;
692 buildInputs = [ openssl libssh2 zlib ];
693 dontUseCmakeConfigure = true;
694 };
695
696 sassc = attrs: {
697 nativeBuildInputs = [ rake ];
698 dontBuild = false;
699 SASS_LIBSASS_PATH = toString libsass;
700 postPatch = ''
701 substituteInPlace lib/sassc/native.rb \
702 --replace 'gem_root = spec.gem_dir' 'gem_root = File.join(__dir__, "../../")'
703 '';
704 } // (lib.optionalAttrs stdenv.isDarwin {
705 # https://github.com/NixOS/nixpkgs/issues/19098
706 buildFlags = [ "--disable-lto" ];
707 });
708
709 scrypt = attrs: lib.optionalAttrs stdenv.isDarwin {
710 dontBuild = false;
711 postPatch = ''
712 sed -i -e "s/-arch i386//" Rakefile ext/scrypt/Rakefile
713 '';
714 };
715
716 semian = attrs: {
717 buildInputs = [ openssl ];
718 };
719
720 sequel_pg = attrs: {
721 buildInputs = [ postgresql ];
722 };
723
724 snappy = attrs: {
725 buildInputs = [ args.snappy ];
726 };
727
728 sqlite3 = attrs: if lib.versionAtLeast attrs.version "1.5.0"
729 then {
730 nativeBuildInputs = [ pkg-config ];
731 buildInputs = [ sqlite ];
732 buildFlags = [
733 "--enable-system-libraries"
734 ];
735 }
736 else {
737 buildFlags = [
738 "--with-sqlite3-include=${sqlite.dev}/include"
739 "--with-sqlite3-lib=${sqlite.out}/lib"
740 ];
741 };
742
743 rb-readline = attrs: {
744 dontBuild = false;
745 postPatch = ''
746 substituteInPlace lib/rbreadline.rb \
747 --replace 'infocmp' '${ncurses}/bin/infocmp'
748 '';
749 };
750
751 taglib-ruby = attrs: {
752 buildInputs = [ taglib ];
753 };
754
755 timfel-krb5-auth = attrs: {
756 buildInputs = [ libkrb5 ];
757 };
758
759 tiny_tds = attrs: {
760 nativeBuildInputs = [ pkg-config openssl ];
761 buildInputs = [ freetds ];
762 };
763
764 treetop = attrs: {
765 meta.mainProgram = "tt";
766 };
767
768 typhoeus = attrs: {
769 buildInputs = [ curl ];
770 };
771
772 tzinfo = attrs: lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") {
773 dontBuild = false;
774 postPatch =
775 let
776 path = if lib.versionAtLeast attrs.version "2.0"
777 then "lib/tzinfo/data_sources/zoneinfo_data_source.rb"
778 else "lib/tzinfo/zoneinfo_data_source.rb";
779 in
780 ''
781 substituteInPlace ${path} \
782 --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
783 '';
784 };
785
786 uuid4r = attrs: {
787 buildInputs = [ which libossp_uuid ];
788 };
789
790 whois = attrs: {
791 meta.mainProgram = "whoisrb";
792 };
793
794 xapian-ruby = attrs: {
795 # use the system xapian
796 dontBuild = false;
797 nativeBuildInputs = [ rake pkg-config bundler ];
798 buildInputs = [ xapian zlib ];
799 postPatch = ''
800 cp ${./xapian-Rakefile} Rakefile
801 '';
802 preInstall = ''
803 export XAPIAN_CONFIG=${xapian}/bin/xapian-config
804 '';
805 };
806
807 zlib = attrs: {
808 buildInputs = [ zlib ];
809 };
810
811 zookeeper = attrs: {
812 buildInputs = lib.optionals stdenv.isDarwin [ cctools ];
813 };
814}