tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
ruby: allow for passing build arguments
Charles Strahan
11 years ago
5f1622e9
7d8b2f0d
+25
-3
1 changed file
expand all
collapse all
unified
split
pkgs
development
interpreters
ruby
bundler-env.nix
+25
-3
pkgs/development/interpreters/ruby/bundler-env.nix
···
8
8
# This is a work-in-progress.
9
9
# The idea is that his will replace load-ruby-env.nix.
10
10
11
11
-
{ name, gemset, gemfile, lockfile, ruby ? defs.ruby, fixes ? gemFixes }@args:
11
11
+
{ name, gemset, gemfile, lockfile, ruby ? defs.ruby, fixes ? gemFixes
12
12
+
, enableParallelBuilding ? false # TODO: this might not work, given the env-var shinanigans.
13
13
+
, documentation ? false}@args:
12
14
13
15
let
16
16
+
17
17
+
shellEscape = x: "'${lib.replaceChars ["'"] [("'\\'" + "'")] x}'";
14
18
const = x: y: x;
15
19
bundler = bundler_HEAD.override { inherit ruby; };
16
20
inherit (builtins) attrValues;
···
128
132
then acc
129
133
else acc + ''
130
134
cp ${writeScript "${next.name}-pre-install" ''
131
131
-
#!/bin/sh
135
135
+
#!${stdenv.shell}
132
136
133
137
buildInputs="${toString (next.buildInputs or [])}"
134
138
nativeBuildInputs="${toString (next.nativeBuildInputs or [])}"
···
227
231
end
228
232
'';
229
233
234
234
+
needsBuildArgs = attrs: attrs ? buildArgs;
235
235
+
236
236
+
mkBuildArgs = spec:
237
237
+
"export BUNDLE_BUILD__${lib.toUpper spec.name}='${lib.concatStringsSep " " (map shellEscape spec.buildArgs)}'";
238
238
+
239
239
+
allBuildArgs =
240
240
+
lib.concatStringsSep "\n"
241
241
+
(map mkBuildArgs
242
242
+
(lib.filter needsBuildArgs (attrValues instantiated)));
243
243
+
230
244
in
231
245
232
246
stdenv.mkDerivation {
···
262
276
mkdir pre-installers
263
277
${createPreInstallers}
264
278
279
279
+
${allBuildArgs}
280
280
+
281
281
+
${lib.optionalString (!documentation) ''
282
282
+
mkdir home
283
283
+
HOME="$(pwd -P)/home"
284
284
+
echo "gem: --no-rdoc --no-ri" > $HOME/.gemrc
285
285
+
''}
286
286
+
265
287
mkdir $out/bin
266
288
cp ${./monkey_patches.rb} monkey_patches.rb
267
289
export RUBYOPT="-rmonkey_patches.rb -I $(pwd -P)"
268
268
-
bundler install --frozen --binstubs
290
290
+
bundler install --frozen --binstubs ${lib.optionalString enableParallelBuilding "--jobs $NIX_BUILD_CORES"}
269
291
'';
270
292
passthru = {
271
293
inherit ruby;