ruby: make buildInputs work
This commit is contained in:
parent
dfc225d143
commit
7d8b2f0d60
@ -121,7 +121,7 @@ let
|
|||||||
);
|
);
|
||||||
|
|
||||||
needsPreInstall = attrs:
|
needsPreInstall = attrs:
|
||||||
(attrs ? preInstall) || (attrs ? buildInputs);
|
(attrs ? preInstall) || (attrs ? buildInputs) || (attrs ? nativeBuildInputs);
|
||||||
|
|
||||||
createPreInstallers = lib.fold (next: acc:
|
createPreInstallers = lib.fold (next: acc:
|
||||||
if !needsPreInstall next
|
if !needsPreInstall next
|
||||||
@ -129,12 +129,15 @@ let
|
|||||||
else acc + ''
|
else acc + ''
|
||||||
cp ${writeScript "${next.name}-pre-install" ''
|
cp ${writeScript "${next.name}-pre-install" ''
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
buildInputs="${toString (next.buildInputs or [])}"
|
buildInputs="${toString (next.buildInputs or [])}"
|
||||||
|
nativeBuildInputs="${toString (next.nativeBuildInputs or [])}"
|
||||||
|
|
||||||
source ${stdenv}/setup
|
source ${stdenv}/setup
|
||||||
|
|
||||||
${next.preInstall or ""}
|
${next.preInstall or ""}
|
||||||
|
|
||||||
${ruby}/bin/ruby -e 'ENV.inspect' > env/${next.name}
|
${ruby}/bin/ruby -e 'print ENV.inspect' > env/${next.name}
|
||||||
''} pre-installers/${next.name}
|
''} pre-installers/${next.name}
|
||||||
''
|
''
|
||||||
) "" (attrValues instantiated);
|
) "" (attrValues instantiated);
|
||||||
|
@ -5,7 +5,7 @@ buildRubyGem {
|
|||||||
src = fetchgit {
|
src = fetchgit {
|
||||||
url = "https://github.com/bundler/bundler.git";
|
url = "https://github.com/bundler/bundler.git";
|
||||||
rev = "a2343c9eabf5403d8ffcbca4dea33d18a60fc157";
|
rev = "a2343c9eabf5403d8ffcbca4dea33d18a60fc157";
|
||||||
sha256 = "1f0isjrn4rwak3q6sbs6v6gqhwln32gv2dbd98r902nkg9i7y5i0";
|
sha256 = "1l4r55n1wzr817l225l6pm97li1mxg9icd8s51cpfihh91nkdz68";
|
||||||
leaveDotGit = true;
|
leaveDotGit = true;
|
||||||
};
|
};
|
||||||
dontPatchShebangs = true;
|
dontPatchShebangs = true;
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
require 'bundler'
|
require 'bundler'
|
||||||
|
|
||||||
|
# Undo the RUBYOPT trickery.
|
||||||
|
opt = ENV['RUBYOPT'].dup
|
||||||
|
opt.gsub!(/-rmonkey_patches.rb -I [^ ]*/, '')
|
||||||
|
ENV['RUBYOPT'] = opt
|
||||||
|
|
||||||
Bundler.module_eval do
|
Bundler.module_eval do
|
||||||
class << self
|
class << self
|
||||||
# mappings from original uris to store paths.
|
# mappings from original uris to store paths.
|
||||||
@ -21,12 +26,12 @@ Bundler.module_eval do
|
|||||||
# swap out ENV
|
# swap out ENV
|
||||||
def nix_with_env(env, &block)
|
def nix_with_env(env, &block)
|
||||||
if env
|
if env
|
||||||
|
old_env = ENV.to_hash
|
||||||
begin
|
begin
|
||||||
old_env = ENV.to_h
|
|
||||||
ENV.replace(env)
|
ENV.replace(env)
|
||||||
block.call
|
block.call
|
||||||
ensure
|
ensure
|
||||||
ENV.replace old_env
|
ENV.replace(old_env)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
block.call
|
block.call
|
||||||
@ -131,7 +136,15 @@ Bundler::Installer.class_eval do
|
|||||||
pre_installer = "pre-installers/#{spec.name}"
|
pre_installer = "pre-installers/#{spec.name}"
|
||||||
if File.exist?(pre_installer)
|
if File.exist?(pre_installer)
|
||||||
system(pre_installer)
|
system(pre_installer)
|
||||||
|
unless $?.success?
|
||||||
|
Bundler.ui.error "The pre-installer script for #{spec.name} failed!"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
env = eval(Bundler.read_file("env/#{spec.name}"))
|
env = eval(Bundler.read_file("env/#{spec.name}"))
|
||||||
|
unless env
|
||||||
|
Bundler.ui.error "The environment variables for #{spec.name} could not be loaded!"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
Bundler.nix_with_env(env) do
|
Bundler.nix_with_env(env) do
|
||||||
original_install_gem_from_spec(spec, standalone, worker)
|
original_install_gem_from_spec(spec, standalone, worker)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user