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{
21 lib,
22 fetchurl,
23 fetchpatch,
24 fetchpatch2,
25 writeScript,
26 ruby,
27 libkrb5,
28 libxml2,
29 libxslt,
30 python2,
31 stdenv,
32 which,
33 libiconv,
34 libpq,
35 nodejs,
36 clang,
37 sqlite,
38 zlib,
39 imagemagick,
40 lasem,
41 pkg-config,
42 ncurses,
43 xapian,
44 gpgme,
45 util-linux,
46 tzdata,
47 icu,
48 libffi,
49 libdeflate,
50 xz,
51 zstd,
52 libwebp,
53 cmake,
54 libssh2,
55 openssl,
56 openssl_1_1,
57 libmysqlclient,
58 git,
59 perl,
60 pcre2,
61 gecode_3,
62 curl,
63 libsodium,
64 snappy,
65 libossp_uuid,
66 lxc,
67 libpcap,
68 xorg,
69 gtk3,
70 lerc,
71 buildRubyGem,
72 cairo,
73 expat,
74 re2,
75 rake,
76 gobject-introspection,
77 gdk-pixbuf,
78 zeromq,
79 czmq,
80 graphicsmagick,
81 libcxx,
82 file,
83 libvirt,
84 glib,
85 vips,
86 taglib,
87 libopus,
88 linux-pam,
89 libidn,
90 protobuf,
91 fribidi,
92 harfbuzz,
93 bison,
94 flex,
95 pango,
96 python3,
97 patchelf,
98 binutils,
99 freetds,
100 wrapGAppsHook3,
101 atk,
102 bundler,
103 libsass,
104 dart-sass,
105 libexif,
106 libselinux,
107 libsepol,
108 shared-mime-info,
109 libthai,
110 libdatrie,
111 DarwinTools,
112 cctools,
113 libtool,
114 discount,
115 exiv2,
116 libepoxy,
117 libxkbcommon,
118 libmaxminddb,
119 libyaml,
120 cargo,
121 rustc,
122 rustPlatform,
123 libsysprof-capture,
124 imlib2,
125 autoSignDarwinBinariesHook,
126}@args:
127
128let
129 rainbow_rake = buildRubyGem {
130 pname = "rake";
131 gemName = "rake";
132 source.sha256 = "01j8fc9bqjnrsxbppncai05h43315vmz9fwg28qdsgcjw9ck1d7n";
133 type = "gem";
134 version = "12.0.0";
135 };
136in
137
138{
139 ZenTest = attrs: {
140 meta.mainProgram = "zentest";
141 };
142
143 atk = attrs: {
144 dependencies = attrs.dependencies ++ [ "gobject-introspection" ];
145 nativeBuildInputs = [
146 rake
147 bundler
148 pkg-config
149 ]
150 ++ lib.optionals stdenv.hostPlatform.isDarwin [ DarwinTools ];
151 propagatedBuildInputs = [
152 gobject-introspection
153 wrapGAppsHook3
154 atk
155 ];
156 };
157
158 bundler =
159 attrs:
160 let
161 templates = "${attrs.ruby.gemPath}/gems/${attrs.gemName}-${attrs.version}/lib/bundler/templates/";
162 in
163 {
164 # patching shebangs would fail on the templates/Executable file, so we
165 # temporarily remove the executable flag.
166 preFixup = "chmod -x $out/${templates}/Executable";
167 postFixup = ''
168 chmod +x $out/${templates}/Executable
169
170 # Allows to load another bundler version
171 sed -i -e "s/activate_bin_path/bin_path/g" $out/bin/bundle
172 '';
173 };
174
175 cairo = attrs: {
176 nativeBuildInputs = [ pkg-config ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ DarwinTools ];
177 buildInputs = [
178 cairo
179 expat
180 glib
181 libsysprof-capture
182 pcre2
183 xorg.libpthreadstubs
184 xorg.libXdmcp
185 ];
186 };
187
188 cairo-gobject = attrs: {
189 nativeBuildInputs = [ pkg-config ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ DarwinTools ];
190 buildInputs = [
191 cairo
192 expat
193 libsysprof-capture
194 pcre2
195 xorg.libpthreadstubs
196 xorg.libXdmcp
197 ];
198 };
199
200 charlock_holmes = attrs: {
201 buildInputs = [
202 which
203 icu
204 zlib
205 ];
206 };
207
208 cld3 = attrs: {
209 nativeBuildInputs = [ pkg-config ];
210 buildInputs = [ protobuf ];
211 };
212
213 cocoapods-acknowledgements = attrs: {
214 dependencies = attrs.dependencies ++ [ "cocoapods" ];
215 };
216
217 cocoapods-deploy = attrs: {
218 dependencies = [ "cocoapods" ];
219 };
220
221 cocoapods-disable-podfile-validations = attrs: {
222 dependencies = [ "cocoapods" ];
223 };
224
225 cocoapods-generate = attrs: {
226 dependencies = attrs.dependencies ++ [ "cocoapods" ];
227 };
228
229 cocoapods-git_url_rewriter = attrs: {
230 dependencies = [ "cocoapods" ];
231 };
232
233 cocoapods-keys = attrs: {
234 dependencies = attrs.dependencies ++ [ "cocoapods" ];
235 };
236
237 cocoapods-open = attrs: {
238 dependencies = [ "cocoapods" ];
239 };
240
241 cocoapods-try-release-fix = attrs: {
242 dependencies = [ "cocoapods" ];
243 };
244
245 curb = attrs: {
246 buildInputs = [ curl ];
247 };
248
249 curses = attrs: {
250 dontBuild = false;
251 buildInputs = [ ncurses ];
252 patches = lib.optionals (lib.versionOlder attrs.version "1.4.5") [
253 # Fixes incompatible function pointer type error with clang 16. Fixed in 1.4.5 and newer.
254 # Upstream issue: https://github.com/ruby/curses/issues/85
255 (fetchpatch2 {
256 url = "https://github.com/ruby/curses/commit/13e00d07c3aaed83d5f138cf268cc33c9f025d0e.patch?full_index=1";
257 hash = "sha256-ZJ2egqj3Uwmi4KrF79dtwczpwUqFCp52/xQYUymYDmc=";
258 })
259 ];
260 };
261
262 dep-selector-libgecode = attrs: {
263 USE_SYSTEM_GECODE = true;
264 postInstall = ''
265 installPath=$(cat $out/nix-support/gem-meta/install-path)
266 sed -i $installPath/lib/dep-selector-libgecode.rb -e 's@VENDORED_GECODE_DIR =.*@VENDORED_GECODE_DIR = "${gecode_3}"@'
267 '';
268 };
269
270 digest-sha3 = attrs: {
271 hardeningDisable = [ "format" ];
272 };
273
274 rdiscount = attrs: {
275 # Use discount from nixpkgs instead of vendored version
276 dontBuild = false;
277 buildInputs = [ discount ];
278 patches = [
279 # Adapted from Debian:
280 # https://sources.debian.org/data/main/r/ruby-rdiscount/2.1.8-1/debian/patches/01_use-system-libmarkdown.patch
281 ./rdiscount-use-nixpkgs-libmarkdown.patch
282 ];
283 };
284
285 ethon = attrs: {
286 dontBuild = false;
287 postPatch = ''
288 substituteInPlace lib/ethon/curls/settings.rb \
289 --replace "libcurl" "${curl.out}/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary}"
290 '';
291 };
292
293 exiv2 = attrs: {
294 buildFlags = [
295 "--with-exiv2-lib=${exiv2}/lib"
296 "--with-exiv2-include=${exiv2.dev}/include"
297 ];
298 };
299
300 fog-dnsimple =
301 attrs:
302 lib.optionalAttrs (lib.versionOlder attrs.version "1.0.1") {
303 postInstall = ''
304 cd $(cat $out/nix-support/gem-meta/install-path)
305 rm {$out/bin,bin,../../bin}/{setup,console}
306 '';
307 };
308
309 redis-rack = attrs: {
310 dontBuild = false;
311 preBuild = ''
312 exec 3>&1
313 output="$(gem build $gemspec | tee >(cat - >&3))"
314 exec 3>&-
315 sed -i 's!"rake".freeze!!' $gemspec
316 '';
317 };
318
319 ffi-rzmq-core = attrs: {
320 postInstall = ''
321 installPath=$(cat $out/nix-support/gem-meta/install-path)
322 sed -i $installPath/lib/ffi-rzmq-core/libzmq.rb -e 's@inside_gem =.*@inside_gem = "${zeromq}/lib"@'
323 '';
324 };
325
326 mimemagic = attrs: {
327 FREEDESKTOP_MIME_TYPES_PATH = "${shared-mime-info}/share/mime/packages/freedesktop.org.xml";
328 };
329
330 mini_magick = attrs: {
331 postInstall = ''
332 installPath=$(cat $out/nix-support/gem-meta/install-path)
333 echo -e "\nENV['PATH'] += ':${graphicsmagick}/bin'\n" >> $installPath/lib/mini_magick/configuration.rb
334 '';
335 };
336
337 mini_racer = attrs: {
338 buildFlags = [
339 "--with-v8-dir=\"${nodejs.libv8}\""
340 ];
341 dontBuild = false;
342 postPatch = ''
343 substituteInPlace ext/mini_racer_extension/extconf.rb \
344 --replace Libv8.configure_makefile '$CPPFLAGS += " -x c++"; Libv8.configure_makefile'
345 '';
346 };
347
348 do_sqlite3 = attrs: {
349 buildInputs = [ sqlite ];
350 };
351
352 eventmachine = attrs: {
353 dontBuild = false;
354 buildInputs = [ openssl ];
355 postPatch = ''
356 substituteInPlace ext/em.cpp \
357 --replace 'if (bind (' 'if (::bind ('
358 '';
359 };
360
361 exif = attrs: {
362 buildFlags = [ "--with-exif-dir=${libexif}" ];
363 buildInputs = [ libexif ];
364 };
365
366 ffi = attrs: {
367 nativeBuildInputs = [ pkg-config ];
368 buildInputs = [ libffi ];
369 };
370
371 fiddle = attrs: {
372 buildInputs = [ libffi ];
373 };
374
375 gdk_pixbuf2 = attrs: {
376 nativeBuildInputs = [
377 pkg-config
378 bundler
379 rake
380 ]
381 ++ lib.optionals stdenv.hostPlatform.isDarwin [ DarwinTools ];
382 propagatedBuildInputs = [
383 gobject-introspection
384 wrapGAppsHook3
385 gdk-pixbuf
386 ];
387 };
388
389 gdk3 = attrs: {
390 nativeBuildInputs = [
391 pkg-config
392 bundler
393 rake
394 ]
395 ++ lib.optionals stdenv.hostPlatform.isDarwin [ DarwinTools ];
396 propagatedBuildInputs = [
397 gobject-introspection
398 wrapGAppsHook3
399 gdk-pixbuf
400 cairo
401 ];
402 };
403
404 gpgme = attrs: {
405 buildInputs = [ gpgme ];
406 nativeBuildInputs = [ pkg-config ];
407 buildFlags = [ "--use-system-libraries" ];
408 };
409
410 gio2 = attrs: {
411 nativeBuildInputs = [
412 pkg-config
413 gobject-introspection
414 ]
415 ++ lib.optionals stdenv.hostPlatform.isDarwin [ DarwinTools ];
416 buildInputs = [
417 glib
418 libsysprof-capture
419 pcre2
420 ]
421 ++ lib.optionals stdenv.hostPlatform.isLinux [
422 util-linux
423 libselinux
424 libsepol
425 ];
426 };
427
428 gitlab-markup = attrs: { meta.priority = 1; };
429
430 gitlab-pg_query =
431 attrs:
432 lib.optionalAttrs (attrs.version == "1.3.1") {
433 dontBuild = false;
434 postPatch = ''
435 sed -i "s;'https://codeload.github.com.*';'${
436 fetchurl {
437 url = "https://codeload.github.com/lfittl/libpg_query/tar.gz/10-1.0.3";
438 sha256 = "0jfij8apzxsdabl70j42xgd5f3ka1gdcrk764nccp66164gpcchk";
439 }
440 }';" ext/pg_query/extconf.rb
441 '';
442 };
443
444 parser = attrs: {
445 meta.mainProgram = "ruby-parse";
446 };
447
448 pg_query =
449 attrs:
450 lib.optionalAttrs (attrs.version == "2.0.2") {
451 dontBuild = false;
452 postPatch = ''
453 sed -i "s;'https://codeload.github.com.*';'${
454 fetchurl {
455 url = "https://codeload.github.com/lfittl/libpg_query/tar.gz/13-2.0.2";
456 sha256 = "0ms2s6hmy8qyzv4g1hj4i2p5fws1v8lrj73b2knwbp2ipd45yj7y";
457 }
458 }';" ext/pg_query/extconf.rb
459 '';
460 }
461 // lib.optionalAttrs (attrs.version == "1.3.0") {
462 # Needed for gitlab
463 dontBuild = false;
464 postPatch = ''
465 sed -i "s;'https://codeload.github.com.*';'${
466 fetchurl {
467 url = "https://codeload.github.com/lfittl/libpg_query/tar.gz/10-1.0.4";
468 sha256 = "0f0kshhai0pnkqj0w4kgz3fssnvwidllc31n1fysxjjzdqlr1k48";
469 }
470 }';" ext/pg_query/extconf.rb
471 '';
472 };
473
474 prettier = attrs: {
475 meta.mainProgram = "rbprettier";
476 };
477
478 prometheus-client-mmap =
479 attrs:
480 {
481 dontBuild = false;
482 postPatch =
483 let
484 getconf = if stdenv.hostPlatform.isGnu then stdenv.cc.libc else getconf;
485 in
486 ''
487 substituteInPlace lib/prometheus/client/page_size.rb --replace "getconf" "${lib.getBin getconf}/bin/getconf"
488 '';
489 }
490 // lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") {
491 cargoDeps = rustPlatform.fetchCargoVendor {
492 src = stdenv.mkDerivation {
493 inherit (buildRubyGem { inherit (attrs) gemName version source; })
494 name
495 src
496 unpackPhase
497 nativeBuildInputs
498 ;
499 dontBuilt = true;
500 installPhase = ''
501 cp -R ext/fast_mmaped_file_rs $out
502 rm $out/Cargo.lock
503 cp Cargo.lock $out
504 '';
505 };
506 hash = "sha256-mukk+tWWeG62q4GcDzkk8TyxVsDjShz30wEj82cElt4=";
507 };
508
509 nativeBuildInputs = [
510 cargo
511 rustc
512 rustPlatform.cargoSetupHook
513 rustPlatform.bindgenHook
514 ];
515
516 disallowedReferences = [
517 rustc.unwrapped
518 ];
519
520 preInstall = ''
521 export CARGO_HOME="$PWD/../.cargo/"
522 '';
523
524 postInstall = ''
525 find $out -type f -name .rustc_info.json -delete
526 '';
527 };
528
529 glib2 = attrs: {
530 nativeBuildInputs = [ pkg-config ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ DarwinTools ];
531 buildInputs = [
532 glib
533 libsysprof-capture
534 pcre2
535 ];
536 };
537
538 gtk3 = attrs: {
539 nativeBuildInputs = [
540 binutils
541 pkg-config
542 ]
543 ++ lib.optionals stdenv.hostPlatform.isLinux [
544 util-linux
545 libselinux
546 libsepol
547 ]
548 ++ lib.optionals stdenv.hostPlatform.isDarwin [ DarwinTools ];
549 propagatedBuildInputs = [
550 atk
551 gdk-pixbuf
552 fribidi
553 gobject-introspection
554 gtk3
555 libdeflate
556 xz
557 libwebp
558 zstd
559 cairo
560 harfbuzz
561 lerc
562 libdatrie
563 libsysprof-capture
564 libthai
565 pcre2
566 xorg.libpthreadstubs
567 xorg.libXdmcp
568 xorg.libXtst
569 libxkbcommon
570 libepoxy
571 ];
572 dontStrip = stdenv.hostPlatform.isDarwin;
573 };
574
575 gobject-introspection = attrs: {
576 nativeBuildInputs = [ pkg-config ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ DarwinTools ];
577 propagatedBuildInputs = [
578 gobject-introspection
579 wrapGAppsHook3
580 glib
581 pcre2
582 libsysprof-capture
583 ];
584 };
585
586 gollum = attrs: {
587 dontBuild = false;
588 postPatch = ''
589 substituteInPlace bin/gollum \
590 --replace "/usr/bin/env -S ruby" "${ruby}/bin/ruby"
591 '';
592 };
593
594 google-protobuf =
595 attrs:
596 lib.optionalAttrs (lib.versionAtLeast attrs.version "3.25.0") {
597 # Fails on 3.25.0 with:
598 # convert.c:312:32: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
599 hardeningDisable = [ "format" ];
600 };
601
602 grpc = attrs: {
603 nativeBuildInputs = [
604 pkg-config
605 ]
606 ++ lib.optional stdenv.hostPlatform.isDarwin cctools
607 ++ lib.optional (
608 lib.versionAtLeast attrs.version "1.53.0"
609 && stdenv.hostPlatform.isDarwin
610 && stdenv.hostPlatform.isAarch64
611 ) autoSignDarwinBinariesHook;
612 buildInputs = [ openssl ];
613 hardeningDisable = [ "format" ];
614 env = lib.optionalAttrs (lib.versionOlder attrs.version "1.68.1") {
615 NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types";
616 };
617 patches = lib.optionals (lib.versionOlder attrs.version "1.65.0") [
618 (fetchpatch {
619 name = "gcc-14-fixes.patch";
620 url = "https://boringssl.googlesource.com/boringssl/+/c70190368c7040c37c1d655f0690bcde2b109a0d%5E%21/?format=TEXT";
621 decode = "base64 -d";
622 stripLen = 1;
623 extraPrefix = "third_party/boringssl-with-bazel/src/";
624 hash = "sha256-1QyQm5s55op268r72dfExNGV+UyV5Ty6boHa9DQq40U=";
625 })
626 ];
627 dontBuild = false;
628 postPatch = ''
629 substituteInPlace Makefile \
630 --replace '-Wno-invalid-source-encoding' ""
631 ''
632 + lib.optionalString (lib.versionOlder attrs.version "1.53.0" && stdenv.hostPlatform.isDarwin) ''
633 # For < v1.48.0
634 substituteInPlace src/ruby/ext/grpc/extconf.rb \
635 --replace "ENV['AR'] = 'libtool -o' if RUBY_PLATFORM =~ /darwin/" ""
636 # For >= v1.48.0
637 substituteInPlace src/ruby/ext/grpc/extconf.rb \
638 --replace 'apple_toolchain = ' 'apple_toolchain = false && '
639 '';
640 };
641
642 hiredis-client = attrs: {
643 buildInputs = [
644 openssl
645 ];
646 };
647
648 hpricot = attrs: {
649 dontBuild = false;
650 patches = [
651 # Fix incompatible function pointer conversion errors with clang 16
652 ./hpricot-fix-incompatible-function-pointer-conversion.patch
653 ];
654 };
655
656 iconv = attrs: {
657 buildFlags = lib.optionals stdenv.hostPlatform.isDarwin [
658 "--with-iconv-dir=${lib.getLib libiconv}"
659 "--with-iconv-include=${lib.getDev libiconv}/include"
660 ];
661 };
662
663 idn-ruby = attrs: {
664 buildInputs = [ libidn ];
665 };
666
667 # disable bundle install as it can't install anything in addition to what is
668 # specified in pkgs/applications/misc/jekyll/Gemfile anyway. Also do chmod_R
669 # to compensate for read-only files in site_template in nix store.
670 jekyll = attrs: {
671 postInstall = ''
672 installPath=$(cat $out/nix-support/gem-meta/install-path)
673 sed -i $installPath/lib/jekyll/commands/new.rb \
674 -e 's@Exec.run("bundle", "install"@Exec.run("true"@' \
675 -e 's@FileUtils.cp_r site_template + "/.", path@FileUtils.cp_r site_template + "/.", path; FileUtils.chmod_R "u+w", path@'
676 '';
677 };
678
679 execjs = attrs: {
680 propagatedBuildInputs = [ nodejs.libv8 ];
681 };
682
683 libxml-ruby = attrs: {
684 buildFlags = [
685 "--with-xml2-lib=${libxml2.out}/lib"
686 "--with-xml2-include=${libxml2.dev}/include/libxml2"
687 ]
688 ++ lib.optionals stdenv.hostPlatform.isDarwin [
689 "--with-iconv-dir=${lib.getLib libiconv}"
690 "--with-opt-include=${lib.getDev libiconv}/include"
691 ];
692 };
693
694 mathematical = attrs: {
695 nativeBuildInputs = [
696 ruby
697 cmake
698 bison
699 flex
700 pkg-config
701 python3
702 patchelf
703 ];
704
705 buildInputs = [
706 cairo
707 fribidi
708 gdk-pixbuf
709 glib
710 libxml2
711 pango
712 ];
713
714 strictDeps = true;
715
716 # The ruby build script takes care of this
717 dontUseCmakeConfigure = true;
718
719 postInstall = ''
720 # Reduce output size by a lot, and remove some unnecessary references.
721 # The ext directory should only be required at build time, so
722 # can be deleted now.
723 rm -r $out/${ruby.gemPath}/gems/mathematical-${attrs.version}/ext \
724 $out/${ruby.gemPath}/extensions/*/*/mathematical-${attrs.version}/gem_make.out
725 '';
726
727 # For some reason 'mathematical.so' is missing cairo, glib, and
728 # lasem in its RPATH, add them explicitly here
729 postFixup =
730 lib.optionalString stdenv.hostPlatform.isLinux ''
731 soPath="$out/${ruby.gemPath}/gems/mathematical-${attrs.version}/lib/mathematical/mathematical.so"
732 rpath="$(patchelf --print-rpath "$soPath")"
733 patchelf --set-rpath "${
734 lib.makeLibraryPath [
735 lasem
736 glib
737 cairo
738 ]
739 }:$rpath" "$soPath"
740 patchelf --replace-needed liblasem.so liblasem-0.4.so "$soPath"
741 ''
742 + lib.optionalString stdenv.hostPlatform.isDarwin ''
743 soPath="$out/${ruby.gemPath}/gems/mathematical-${attrs.version}/lib/mathematical/mathematical.bundle"
744 install_name_tool -add_rpath "${
745 lib.makeLibraryPath [
746 lasem
747 glib
748 cairo
749 ]
750 }/lib" "$soPath"
751 install_name_tool -change @rpath/liblasem.dylib "${lib.getLib lasem}/lib/liblasem-0.4.dylib" "$soPath"
752 '';
753 };
754
755 magic = attrs: {
756 buildInputs = [ file ];
757 postInstall = ''
758 installPath=$(cat $out/nix-support/gem-meta/install-path)
759 sed -e 's@ENV\["MAGIC_LIB"\] ||@ENV\["MAGIC_LIB"\] || "${file}/lib/libmagic.so" ||@' -i $installPath/lib/magic/api.rb
760 '';
761 };
762
763 maxmind_geoip2 = attrs: {
764 buildFlags = [
765 "--with-maxminddb-lib=${libmaxminddb}/lib"
766 "--with-maxminddb-include=${libmaxminddb}/include"
767 ];
768 };
769
770 metasploit-framework = attrs: {
771 preInstall = ''
772 export HOME=$TMPDIR
773 '';
774 };
775
776 mysql = attrs: {
777 buildInputs = [
778 libmysqlclient
779 zlib
780 openssl
781 ];
782 };
783
784 mysql2 = attrs: {
785 buildInputs = [
786 libmysqlclient
787 zlib
788 openssl
789 ];
790 };
791
792 ncursesw = attrs: {
793 buildInputs = [ ncurses ];
794 buildFlags = [
795 "--with-cflags=-I${ncurses.dev}/include"
796 "--with-ldflags=-L${ncurses.out}/lib"
797 ];
798 };
799
800 nokogiri =
801 attrs:
802 (
803 {
804 buildFlags = [
805 "--use-system-libraries"
806 "--with-zlib-lib=${zlib.out}/lib"
807 "--with-zlib-include=${zlib.dev}/include"
808 "--with-xml2-lib=${libxml2.out}/lib"
809 "--with-xml2-include=${libxml2.dev}/include/libxml2"
810 "--with-xslt-lib=${libxslt.out}/lib"
811 "--with-xslt-include=${libxslt.dev}/include"
812 "--with-exslt-lib=${libxslt.out}/lib"
813 "--with-exslt-include=${libxslt.dev}/include"
814 ]
815 ++ lib.optionals stdenv.hostPlatform.isDarwin [
816 "--with-iconv-dir=${libiconv}"
817 "--with-opt-include=${libiconv}/include"
818 ];
819 }
820 // lib.optionalAttrs stdenv.hostPlatform.isDarwin {
821 buildInputs = [ libxml2 ];
822
823 # libxml 2.12 upgrade requires these fixes
824 # https://github.com/sparklemotion/nokogiri/pull/3032
825 # which don't trivially apply to older versions
826 meta.broken =
827 (lib.versionOlder attrs.version "1.16.0") && (lib.versionAtLeast libxml2.version "2.12");
828 }
829 );
830
831 openssl = attrs: {
832 # https://github.com/ruby/openssl/issues/369
833 buildInputs = [ (if (lib.versionAtLeast attrs.version "3.0.0") then openssl else openssl_1_1) ];
834 };
835
836 opus-ruby = attrs: {
837 dontBuild = false;
838 postPatch = ''
839 substituteInPlace lib/opus-ruby.rb \
840 --replace "ffi_lib 'opus'" \
841 "ffi_lib '${libopus}/lib/libopus${stdenv.hostPlatform.extensions.sharedLibrary}'"
842 '';
843 };
844
845 ovirt-engine-sdk = attrs: {
846 buildInputs = [
847 curl
848 libxml2
849 ];
850 # https://github.com/oVirt/ovirt-engine-sdk-ruby/issues/13
851 env.NIX_CFLAGS_COMPILE = toString [
852 "-Wno-error=implicit-function-declaration"
853 "-Wno-error=incompatible-pointer-types"
854 "-Wno-int-conversion"
855 ];
856 dontBuild = false;
857 meta.broken = stdenv.hostPlatform.isDarwin; # At least until releasing https://github.com/oVirt/ovirt-engine-sdk-ruby/pull/17
858 };
859
860 pango = attrs: {
861 nativeBuildInputs = [
862 pkg-config
863 ]
864 ++ lib.optionals stdenv.hostPlatform.isDarwin [ DarwinTools ];
865 buildInputs = [
866 libdatrie
867 libthai
868 fribidi
869 harfbuzz
870 libsysprof-capture
871 pcre2
872 xorg.libpthreadstubs
873 xorg.libXdmcp
874 ]
875 ++ lib.optionals stdenv.hostPlatform.isLinux [
876 libselinux
877 libsepol
878 util-linux
879 ];
880 propagatedBuildInputs = [
881 gobject-introspection
882 wrapGAppsHook3
883 ];
884 };
885
886 patron = attrs: {
887 buildInputs = [ curl ];
888 };
889
890 pcaprub = attrs: {
891 buildInputs = [ libpcap ];
892 };
893
894 pg = attrs: {
895 # Force pkg-config lookup for libpq.
896 # See https://github.com/ged/ruby-pg/blob/6629dec6656f7ca27619e4675b45225d9e422112/ext/extconf.rb#L34-L55
897 #
898 # Note that setting --with-pg-config=${postgresql.pg_config}/bin/pg_config would add
899 # an unnecessary reference to the entire postgresql package.
900 buildFlags = [ "--with-pg-config=ignore" ];
901 nativeBuildInputs = [ pkg-config ];
902 buildInputs = [ libpq ];
903 };
904
905 rszr = attrs: {
906 buildInputs = [
907 imlib2
908 imlib2.dev
909 ];
910 buildFlags = [ "--without-imlib2-config" ];
911 };
912
913 psych = attrs: {
914 buildInputs = [ libyaml ];
915 };
916
917 puma = attrs: {
918 buildInputs = [ openssl ];
919 };
920
921 "pygments.rb" = attrs: {
922 buildInputs = [ python3 ];
923 };
924
925 rack = attrs: {
926 meta.mainProgram = "rackup";
927 };
928
929 railties = attrs: {
930 meta.mainProgram = "rails";
931 };
932
933 rainbow = attrs: {
934 buildInputs = [ rainbow_rake ];
935 };
936
937 rbczmq =
938 { ... }:
939 {
940 buildInputs = [
941 zeromq
942 czmq
943 ];
944 buildFlags = [ "--with-system-libs" ];
945 };
946
947 rbnacl =
948 spec:
949 if lib.versionOlder spec.version "6.0.0" then
950 {
951 postInstall = ''
952 sed -i $(cat $out/nix-support/gem-meta/install-path)/lib/rbnacl.rb -e "2a \
953 RBNACL_LIBSODIUM_GEM_LIB_PATH = '${libsodium.out}/lib/libsodium${stdenv.hostPlatform.extensions.sharedLibrary}'
954 "
955 '';
956 }
957 else
958 {
959 dontBuild = false;
960 postPatch = ''
961 substituteInPlace lib/rbnacl/sodium.rb \
962 --replace 'ffi_lib ["sodium"' \
963 'ffi_lib ["${libsodium}/lib/libsodium${stdenv.hostPlatform.extensions.sharedLibrary}"'
964 '';
965 };
966
967 re2 = attrs: {
968 buildInputs = [ re2 ];
969 buildFlags = [
970 "--enable-system-libraries"
971 ];
972 };
973
974 rest-client = attrs: {
975 meta.mainProgram = "restclient";
976 };
977
978 rmagick = attrs: {
979 nativeBuildInputs = [ pkg-config ];
980 buildInputs = [
981 imagemagick
982 which
983 ];
984 };
985
986 rouge = attrs: {
987 meta.mainProgram = "rougify";
988 };
989
990 rpam2 = attrs: {
991 buildInputs = [ linux-pam ];
992 };
993
994 rspec-core = attrs: {
995 meta.mainProgram = "rspec";
996 };
997
998 ruby-libvirt = attrs: {
999 nativeBuildInputs = [ pkg-config ];
1000 buildInputs = [ libvirt ];
1001 buildFlags = [
1002 "--with-libvirt-include=${libvirt}/include"
1003 "--with-libvirt-lib=${libvirt}/lib"
1004 ];
1005 };
1006
1007 ruby-lxc = attrs: {
1008 buildInputs = [ lxc ];
1009 };
1010
1011 ruby-terminfo = attrs: {
1012 buildInputs = [ ncurses ];
1013 buildFlags = [
1014 "--with-cflags=-I${ncurses.dev}/include"
1015 "--with-ldflags=-L${ncurses.out}/lib"
1016 ];
1017 dontBuild = false;
1018 postPatch = ''
1019 substituteInPlace extconf.rb --replace 'rubyio.h' 'ruby/io.h'
1020 substituteInPlace terminfo.c \
1021 --replace 'rubyio.h' 'ruby/io.h' \
1022 --replace 'rb_cData' 'rb_cObject'
1023 '';
1024 };
1025
1026 ruby-vips = attrs: {
1027 postInstall = ''
1028 cd "$(cat $out/nix-support/gem-meta/install-path)"
1029
1030 substituteInPlace lib/vips.rb \
1031 --replace 'library_name("vips", 42)' '"${lib.getLib vips}/lib/libvips${stdenv.hostPlatform.extensions.sharedLibrary}"' \
1032 --replace 'library_name("glib-2.0", 0)' '"${glib.out}/lib/libglib-2.0${stdenv.hostPlatform.extensions.sharedLibrary}"' \
1033 --replace 'library_name("gobject-2.0", 0)' '"${glib.out}/lib/libgobject-2.0${stdenv.hostPlatform.extensions.sharedLibrary}"'
1034 '';
1035 };
1036
1037 rugged = attrs: {
1038 nativeBuildInputs = [
1039 cmake
1040 pkg-config
1041 which
1042 ]
1043 ++ lib.optional stdenv.hostPlatform.isDarwin libiconv;
1044 buildInputs = [
1045 openssl
1046 libssh2
1047 zlib
1048 ];
1049 dontUseCmakeConfigure = true;
1050 buildFlags = [ "--with-ssh" ];
1051 };
1052
1053 sassc = attrs: {
1054 nativeBuildInputs = [ rake ];
1055 dontBuild = false;
1056 SASS_LIBSASS_PATH = toString libsass;
1057 postPatch = ''
1058 substituteInPlace lib/sassc/native.rb \
1059 --replace 'gem_root = spec.gem_dir' 'gem_root = File.join(__dir__, "../../")'
1060 '';
1061 };
1062
1063 sass-embedded = attrs: {
1064 # Patch the Rakefile to use our dart-sass and not try to fetch anything.
1065 dontBuild = false;
1066 postPatch = ''
1067 substituteInPlace ext/sass/Rakefile \
1068 --replace \'dart-sass/sass\' \'${dart-sass}/bin/sass\' \
1069 --replace ' => %w[dart-sass]' ""
1070 '';
1071 };
1072
1073 scrypt =
1074 attrs:
1075 lib.optionalAttrs stdenv.hostPlatform.isDarwin {
1076 dontBuild = false;
1077 postPatch = ''
1078 sed -i -e "s/-arch i386//" Rakefile ext/scrypt/Rakefile
1079 '';
1080 };
1081
1082 semian = attrs: {
1083 buildInputs = [ openssl ];
1084 };
1085
1086 sequel_pg = attrs: {
1087 buildInputs = [ libpq ];
1088 };
1089
1090 snappy = attrs: {
1091 buildInputs = [ args.snappy ];
1092 };
1093
1094 sqlite3 =
1095 attrs:
1096 if lib.versionAtLeast attrs.version "1.5.0" then
1097 {
1098 nativeBuildInputs = [ pkg-config ];
1099 buildInputs = [ sqlite ];
1100 buildFlags = [
1101 "--enable-system-libraries"
1102 ];
1103 }
1104 else
1105 {
1106 buildFlags = [
1107 "--with-sqlite3-include=${sqlite.dev}/include"
1108 "--with-sqlite3-lib=${sqlite.out}/lib"
1109 ];
1110 env.NIX_CFLAGS_COMPILE = toString [
1111 "-Wno-error=incompatible-pointer-types"
1112 "-Wno-error=int-conversion"
1113 ];
1114 };
1115
1116 rb-readline = attrs: {
1117 dontBuild = false;
1118 postPatch = ''
1119 substituteInPlace lib/rbreadline.rb \
1120 --replace 'infocmp' '${ncurses}/bin/infocmp'
1121 '';
1122 };
1123
1124 taglib-ruby = attrs: {
1125 buildInputs = [ taglib ];
1126 };
1127
1128 timfel-krb5-auth = attrs: {
1129 buildInputs = [ libkrb5 ];
1130 };
1131
1132 tiny_tds = attrs: {
1133 nativeBuildInputs = [
1134 pkg-config
1135 openssl
1136 ];
1137 buildInputs = [ freetds ];
1138 };
1139
1140 treetop = attrs: {
1141 meta.mainProgram = "tt";
1142 };
1143
1144 typhoeus = attrs: {
1145 buildInputs = [ curl ];
1146 };
1147
1148 tzinfo =
1149 attrs:
1150 lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") {
1151 dontBuild = false;
1152 postPatch =
1153 let
1154 path =
1155 if lib.versionAtLeast attrs.version "2.0" then
1156 "lib/tzinfo/data_sources/zoneinfo_data_source.rb"
1157 else
1158 "lib/tzinfo/zoneinfo_data_source.rb";
1159 in
1160 ''
1161 substituteInPlace ${path} \
1162 --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
1163 '';
1164 };
1165
1166 uuid4r = attrs: {
1167 buildInputs = [
1168 which
1169 libossp_uuid
1170 ];
1171 };
1172
1173 whois = attrs: {
1174 meta.mainProgram = "whoisrb";
1175 };
1176
1177 xapian-ruby = attrs: {
1178 # use the system xapian
1179 dontBuild = false;
1180 nativeBuildInputs = [
1181 rake
1182 pkg-config
1183 bundler
1184 ];
1185 buildInputs = [
1186 xapian
1187 zlib
1188 ];
1189 postPatch = ''
1190 cp ${./xapian-Rakefile} Rakefile
1191 '';
1192 preInstall = ''
1193 export XAPIAN_CONFIG=${xapian}/bin/xapian-config
1194 '';
1195 };
1196
1197 zlib = attrs: {
1198 buildInputs = [ zlib ];
1199 };
1200
1201 zookeeper = attrs: {
1202 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ cctools ];
1203 };
1204}