1# The standard set of gems in nixpkgs including potential fixes.
2#
3# The gemset is derived from two points of entry:
4# - An attrset describing a gem, including version, source and dependencies
5# This is just meta data, most probably automatically generated by a tool
6# like Bundix (https://github.com/aflatter/bundix).
7# {
8# name = "bundler";
9# version = "1.6.5";
10# sha256 = "1s4x0f5by9xs2y24jk6krq5ky7ffkzmxgr4z1nhdykdmpsi2zd0l";
11# dependencies = [ "rake" ];
12# }
13# - An optional derivation that may override how the gem is built. For popular
14# gems that don't behave correctly, fixes are already provided in the form of
15# derivations.
16#
17# This seperates "what to build" (the exact gem versions) from "how to build"
18# (to make gems behave if necessary).
19
20{ lib, fetchurl, writeScript, ruby, kerberos, libxml2, libxslt, python, stdenv, which
21, libiconv, postgresql, v8_3_16_14, clang, sqlite, zlib, imagemagick
22, pkgconfig , ncurses, xapian_1_2_22, gpgme, utillinux, fetchpatch, tzdata, icu, libffi
23, cmake, libssh2, openssl, mysql, darwin, git, perl, pcre, gecode_3, curl
24, libmsgpack, qt48, libsodium, snappy, libossp_uuid, lxc, libpcap, xlibs, gtk2, buildRubyGem
25, cairo, re2, rake, gobjectIntrospection, gdk_pixbuf
26}@args:
27
28let
29 v8 = v8_3_16_14;
30
31 rainbow_rake = buildRubyGem {
32 name = "rake";
33 gemName = "rake";
34 source.sha256 = "01j8fc9bqjnrsxbppncai05h43315vmz9fwg28qdsgcjw9ck1d7n";
35 type = "gem";
36 version = "12.0.0";
37 };
38in
39
40{
41 atk = attrs: {
42 nativeBuildInputs = [ pkgconfig ];
43 buildInputs = [ gtk2 pcre rake ];
44 };
45
46 bundler = attrs:
47 let
48 templates = "${attrs.ruby.gemPath}/gems/${attrs.gemName}-${attrs.version}/lib/bundler/templates/";
49 in {
50 # patching shebangs would fail on the templates/Executable file, so we
51 # temporarily remove the executable flag.
52 preFixup = "chmod -x $out/${templates}/Executable";
53 postFixup = ''
54 chmod +x $out/${templates}/Executable
55
56 # Allows to load another bundler version
57 sed -i -e "s/activate_bin_path/bin_path/g" $out/bin/bundle
58 '';
59 };
60
61 cairo = attrs: {
62 nativeBuildInputs = [ pkgconfig ];
63 buildInputs = [ gtk2 pcre xlibs.libpthreadstubs xlibs.libXdmcp];
64 };
65
66 cairo-gobject = attrs: {
67 nativeBuildInputs = [ pkgconfig ];
68 buildInputs = [ cairo pcre xlibs.libpthreadstubs xlibs.libXdmcp ];
69 };
70
71 capybara-webkit = attrs: {
72 buildInputs = [ qt48 ];
73 };
74
75 charlock_holmes = attrs: {
76 buildInputs = [ which icu zlib ];
77 };
78
79 curb = attrs: {
80 buildInputs = [ curl ];
81 };
82
83 dep-selector-libgecode = attrs: {
84 USE_SYSTEM_GECODE = true;
85 postInstall = ''
86 installPath=$(cat $out/nix-support/gem-meta/install-path)
87 sed -i $installPath/lib/dep-selector-libgecode.rb -e 's@VENDORED_GECODE_DIR =.*@VENDORED_GECODE_DIR = "${gecode_3}"@'
88 '';
89 };
90
91 ethon = attrs: {
92 dontBuild = false;
93 postPatch = ''
94 substituteInPlace lib/ethon/curls/settings.rb \
95 --replace "libcurl" "${curl.out}/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary}"
96 '';
97 };
98
99 eventmachine = attrs: {
100 buildInputs = [ openssl ];
101 };
102
103 ffi = attrs: {
104 nativeBuildInputs = [ pkgconfig ];
105 buildInputs = [ libffi ];
106 };
107
108 gdk_pixbuf2 = attrs: {
109 nativeBuildInputs = [ pkgconfig ];
110 buildInputs = [ rake gdk_pixbuf ];
111 };
112
113 gpgme = attrs: {
114 buildInputs = [ gpgme ];
115 };
116
117 gio2 = attrs: {
118 nativeBuildInputs = [ pkgconfig ];
119 buildInputs = [ gtk2 pcre gobjectIntrospection ];
120 };
121
122 gitlab-markup = attrs: { meta.priority = 1; };
123
124 glib2 = attrs: {
125 nativeBuildInputs = [ pkgconfig ];
126 buildInputs = [ gtk2 pcre ];
127 };
128
129 gtk2 = attrs: {
130 nativeBuildInputs = [ pkgconfig ];
131 buildInputs = [ gtk2 pcre xlibs.libpthreadstubs xlibs.libXdmcp];
132 # CFLAGS must be set for this gem to detect gdkkeysyms.h correctly
133 CFLAGS = "-I${gtk2.dev}/include/gtk-2.0 -I/non-existent-path";
134 };
135
136 gobject-introspection = attrs: {
137 nativeBuildInputs = [ pkgconfig ];
138 buildInputs = [ gobjectIntrospection gtk2 pcre ];
139 };
140
141 grpc = attrs: {
142 nativeBuildInputs = [ pkgconfig ];
143 buildInputs = [ openssl ];
144 NIX_CFLAGS_COMPILE = [ "-Wno-error=stringop-overflow" "-Wno-error=implicit-fallthrough" ];
145 };
146
147 hitimes = attrs: {
148 buildInputs =
149 stdenv.lib.optionals stdenv.isDarwin
150 [ darwin.apple_sdk.frameworks.CoreServices ];
151 };
152
153 # disable bundle install as it can't install anything in addition to what is
154 # specified in pkgs/applications/misc/jekyll/Gemfile anyway. Also do chmod_R
155 # to compensate for read-only files in site_template in nix store.
156 jekyll = attrs: {
157 postInstall = ''
158 installPath=$(cat $out/nix-support/gem-meta/install-path)
159 sed -i $installPath/lib/jekyll/commands/new.rb \
160 -e 's@Exec.run("bundle", "install"@Exec.run("true"@' \
161 -e 's@FileUtils.cp_r site_template + "/.", path@FileUtils.cp_r site_template + "/.", path; FileUtils.chmod_R "u+w", path@'
162 '';
163 };
164
165 # note that you need version >= v3.16.14.8,
166 # otherwise the gem will fail to link to the libv8 binary.
167 # see: https://github.com/cowboyd/libv8/pull/161
168 libv8 = attrs: {
169 buildInputs = [ which v8 python ];
170 buildFlags = [ "--with-system-v8=true" ];
171 };
172
173 msgpack = attrs: {
174 buildInputs = [ libmsgpack ];
175 };
176
177 mysql = attrs: {
178 buildInputs = [ mysql.connector-c zlib openssl ];
179 };
180
181 mysql2 = attrs: {
182 buildInputs = [ mysql.connector-c zlib openssl ];
183 };
184
185 ncursesw = attrs: {
186 buildInputs = [ ncurses ];
187 buildFlags = [
188 "--with-cflags=-I${ncurses.dev}/include"
189 "--with-ldflags=-L${ncurses.out}/lib"
190 ];
191 };
192
193 nokogiri = attrs: {
194 buildFlags = [
195 "--use-system-libraries"
196 "--with-zlib-dir=${zlib.dev}"
197 "--with-xml2-lib=${libxml2.out}/lib"
198 "--with-xml2-include=${libxml2.dev}/include/libxml2"
199 "--with-xslt-lib=${libxslt.out}/lib"
200 "--with-xslt-include=${libxslt.dev}/include"
201 "--with-exslt-lib=${libxslt.out}/lib"
202 "--with-exslt-include=${libxslt.dev}/include"
203 ] ++ lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
204 };
205
206 pango = attrs: {
207 nativeBuildInputs = [ pkgconfig ];
208 buildInputs = [ gtk2 xlibs.libXdmcp pcre xlibs.libpthreadstubs ];
209 };
210
211 patron = attrs: {
212 buildInputs = [ curl ];
213 };
214
215 pcaprub = attrs: {
216 buildInputs = [ libpcap ];
217 };
218
219 pg = attrs: {
220 buildFlags = [
221 "--with-pg-config=${postgresql}/bin/pg_config"
222 ];
223 };
224
225 puma = attrs: {
226 buildInputs = [ openssl ];
227 };
228
229 rainbow = attrs: {
230 buildInputs = [ rainbow_rake ];
231 };
232
233 rbnacl = spec: {
234 postInstall = ''
235 sed -i $(cat $out/nix-support/gem-meta/install-path)/lib/rbnacl.rb -e "2a \
236 RBNACL_LIBSODIUM_GEM_LIB_PATH = '${libsodium.out}/lib/libsodium${stdenv.hostPlatform.extensions.sharedLibrary}'
237 "
238 '';
239 };
240
241 re2 = attrs: {
242 buildInputs = [ re2 ];
243 };
244
245 rmagick = attrs: {
246 nativeBuildInputs = [ pkgconfig ];
247 buildInputs = [ imagemagick which ];
248 };
249
250 ruby-lxc = attrs: {
251 buildInputs = [ lxc ];
252 };
253
254 ruby-terminfo = attrs: {
255 buildInputs = [ ncurses ];
256 buildFlags = [
257 "--with-cflags=-I${ncurses.dev}/include"
258 "--with-ldflags=-L${ncurses.out}/lib"
259 ];
260 };
261 rugged = attrs: {
262 nativeBuildInputs = [ pkgconfig ];
263 buildInputs = [ cmake openssl libssh2 zlib ];
264 };
265
266 scrypt = attrs:
267 if stdenv.isDarwin then {
268 dontBuild = false;
269 postPatch = ''
270 sed -i -e "s/-arch i386//" Rakefile ext/scrypt/Rakefile
271 '';
272 } else {};
273
274 sequel_pg = attrs: {
275 buildInputs = [ postgresql ];
276 };
277
278 snappy = attrs: {
279 buildInputs = [ args.snappy ];
280 };
281
282 sqlite3 = attrs: {
283 buildFlags = [
284 "--with-sqlite3-include=${sqlite.dev}/include"
285 "--with-sqlite3-lib=${sqlite.out}/lib"
286 ];
287 };
288
289 sup = attrs: {
290 dontBuild = false;
291 # prevent sup from trying to dynamically install `xapian-ruby`.
292 postPatch = ''
293 cp ${./mkrf_conf_xapian.rb} ext/mkrf_conf_xapian.rb
294
295 substituteInPlace lib/sup/crypto.rb \
296 --replace 'which gpg2' \
297 '${which}/bin/which gpg'
298 '';
299 };
300
301 rb-readline = attrs: {
302 dontBuild = false;
303 postPatch = ''
304 substituteInPlace lib/rbreadline.rb \
305 --replace 'infocmp' '${ncurses.dev}/bin/infocmp'
306 '';
307 };
308
309 timfel-krb5-auth = attrs: {
310 buildInputs = [ kerberos ];
311 };
312
313 therubyracer = attrs: {
314 buildFlags = [
315 "--with-v8-dir=${v8}"
316 "--with-v8-include=${v8}/include"
317 "--with-v8-lib=${v8}/lib"
318 ];
319 };
320
321 typhoeus = attrs: {
322 buildInputs = [ curl ];
323 };
324
325 tzinfo = attrs: lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") {
326 dontBuild = false;
327 postPatch = ''
328 substituteInPlace lib/tzinfo/zoneinfo_data_source.rb \
329 --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
330 '';
331 };
332
333 uuid4r = attrs: {
334 buildInputs = [ which libossp_uuid ];
335 };
336
337 xapian-ruby = attrs: {
338 # use the system xapian
339 dontBuild = false;
340 nativeBuildInputs = [ pkgconfig ];
341 buildInputs = [ xapian_1_2_22 zlib ];
342 postPatch = ''
343 cp ${./xapian-Rakefile} Rakefile
344 '';
345 preInstall = ''
346 export XAPIAN_CONFIG=${xapian_1_2_22}/bin/xapian-config
347 '';
348 };
349
350}