ruby: allow for passing build arguments
This commit is contained in:
parent
7d8b2f0d60
commit
5f1622e95f
@ -8,9 +8,13 @@
|
|||||||
# This is a work-in-progress.
|
# This is a work-in-progress.
|
||||||
# The idea is that his will replace load-ruby-env.nix.
|
# The idea is that his will replace load-ruby-env.nix.
|
||||||
|
|
||||||
{ name, gemset, gemfile, lockfile, ruby ? defs.ruby, fixes ? gemFixes }@args:
|
{ name, gemset, gemfile, lockfile, ruby ? defs.ruby, fixes ? gemFixes
|
||||||
|
, enableParallelBuilding ? false # TODO: this might not work, given the env-var shinanigans.
|
||||||
|
, documentation ? false}@args:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
shellEscape = x: "'${lib.replaceChars ["'"] [("'\\'" + "'")] x}'";
|
||||||
const = x: y: x;
|
const = x: y: x;
|
||||||
bundler = bundler_HEAD.override { inherit ruby; };
|
bundler = bundler_HEAD.override { inherit ruby; };
|
||||||
inherit (builtins) attrValues;
|
inherit (builtins) attrValues;
|
||||||
@ -128,7 +132,7 @@ let
|
|||||||
then acc
|
then acc
|
||||||
else acc + ''
|
else acc + ''
|
||||||
cp ${writeScript "${next.name}-pre-install" ''
|
cp ${writeScript "${next.name}-pre-install" ''
|
||||||
#!/bin/sh
|
#!${stdenv.shell}
|
||||||
|
|
||||||
buildInputs="${toString (next.buildInputs or [])}"
|
buildInputs="${toString (next.buildInputs or [])}"
|
||||||
nativeBuildInputs="${toString (next.nativeBuildInputs or [])}"
|
nativeBuildInputs="${toString (next.nativeBuildInputs or [])}"
|
||||||
@ -227,6 +231,16 @@ let
|
|||||||
end
|
end
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
needsBuildArgs = attrs: attrs ? buildArgs;
|
||||||
|
|
||||||
|
mkBuildArgs = spec:
|
||||||
|
"export BUNDLE_BUILD__${lib.toUpper spec.name}='${lib.concatStringsSep " " (map shellEscape spec.buildArgs)}'";
|
||||||
|
|
||||||
|
allBuildArgs =
|
||||||
|
lib.concatStringsSep "\n"
|
||||||
|
(map mkBuildArgs
|
||||||
|
(lib.filter needsBuildArgs (attrValues instantiated)));
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
@ -262,10 +276,18 @@ stdenv.mkDerivation {
|
|||||||
mkdir pre-installers
|
mkdir pre-installers
|
||||||
${createPreInstallers}
|
${createPreInstallers}
|
||||||
|
|
||||||
|
${allBuildArgs}
|
||||||
|
|
||||||
|
${lib.optionalString (!documentation) ''
|
||||||
|
mkdir home
|
||||||
|
HOME="$(pwd -P)/home"
|
||||||
|
echo "gem: --no-rdoc --no-ri" > $HOME/.gemrc
|
||||||
|
''}
|
||||||
|
|
||||||
mkdir $out/bin
|
mkdir $out/bin
|
||||||
cp ${./monkey_patches.rb} monkey_patches.rb
|
cp ${./monkey_patches.rb} monkey_patches.rb
|
||||||
export RUBYOPT="-rmonkey_patches.rb -I $(pwd -P)"
|
export RUBYOPT="-rmonkey_patches.rb -I $(pwd -P)"
|
||||||
bundler install --frozen --binstubs
|
bundler install --frozen --binstubs ${lib.optionalString enableParallelBuilding "--jobs $NIX_BUILD_CORES"}
|
||||||
'';
|
'';
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit ruby;
|
inherit ruby;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user