ruby: allow for passing build arguments

+25 -3
+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 - { name, gemset, gemfile, lockfile, ruby ? defs.ruby, fixes ? gemFixes }@args: 11 + { name, gemset, gemfile, lockfile, ruby ? defs.ruby, fixes ? gemFixes 12 + , enableParallelBuilding ? false # TODO: this might not work, given the env-var shinanigans. 13 + , documentation ? false}@args: 12 14 13 15 let 16 + 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 - #!/bin/sh 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 + needsBuildArgs = attrs: attrs ? buildArgs; 235 + 236 + mkBuildArgs = spec: 237 + "export BUNDLE_BUILD__${lib.toUpper spec.name}='${lib.concatStringsSep " " (map shellEscape spec.buildArgs)}'"; 238 + 239 + allBuildArgs = 240 + lib.concatStringsSep "\n" 241 + (map mkBuildArgs 242 + (lib.filter needsBuildArgs (attrValues instantiated))); 243 + 230 244 in 231 245 232 246 stdenv.mkDerivation { ··· 262 276 mkdir pre-installers 263 277 ${createPreInstallers} 264 278 279 + ${allBuildArgs} 280 + 281 + ${lib.optionalString (!documentation) '' 282 + mkdir home 283 + HOME="$(pwd -P)/home" 284 + echo "gem: --no-rdoc --no-ri" > $HOME/.gemrc 285 + ''} 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 - bundler install --frozen --binstubs 290 + bundler install --frozen --binstubs ${lib.optionalString enableParallelBuilding "--jobs $NIX_BUILD_CORES"} 269 291 ''; 270 292 passthru = { 271 293 inherit ruby;