tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
ruby: make buildInputs work
Charles Strahan
11 years ago
7d8b2f0d
dfc225d1
+21
-5
3 changed files
expand all
collapse all
unified
split
pkgs
development
interpreters
ruby
bundler-env.nix
bundler-head.nix
monkey_patches.rb
+5
-2
pkgs/development/interpreters/ruby/bundler-env.nix
···
121
);
122
123
needsPreInstall = attrs:
124
-
(attrs ? preInstall) || (attrs ? buildInputs);
125
126
createPreInstallers = lib.fold (next: acc:
127
if !needsPreInstall next
···
129
else acc + ''
130
cp ${writeScript "${next.name}-pre-install" ''
131
#!/bin/sh
0
132
buildInputs="${toString (next.buildInputs or [])}"
0
0
133
source ${stdenv}/setup
134
135
${next.preInstall or ""}
136
137
-
${ruby}/bin/ruby -e 'ENV.inspect' > env/${next.name}
138
''} pre-installers/${next.name}
139
''
140
) "" (attrValues instantiated);
···
121
);
122
123
needsPreInstall = attrs:
124
+
(attrs ? preInstall) || (attrs ? buildInputs) || (attrs ? nativeBuildInputs);
125
126
createPreInstallers = lib.fold (next: acc:
127
if !needsPreInstall next
···
129
else acc + ''
130
cp ${writeScript "${next.name}-pre-install" ''
131
#!/bin/sh
132
+
133
buildInputs="${toString (next.buildInputs or [])}"
134
+
nativeBuildInputs="${toString (next.nativeBuildInputs or [])}"
135
+
136
source ${stdenv}/setup
137
138
${next.preInstall or ""}
139
140
+
${ruby}/bin/ruby -e 'print ENV.inspect' > env/${next.name}
141
''} pre-installers/${next.name}
142
''
143
) "" (attrValues instantiated);
+1
-1
pkgs/development/interpreters/ruby/bundler-head.nix
···
5
src = fetchgit {
6
url = "https://github.com/bundler/bundler.git";
7
rev = "a2343c9eabf5403d8ffcbca4dea33d18a60fc157";
8
-
sha256 = "1f0isjrn4rwak3q6sbs6v6gqhwln32gv2dbd98r902nkg9i7y5i0";
9
leaveDotGit = true;
10
};
11
dontPatchShebangs = true;
···
5
src = fetchgit {
6
url = "https://github.com/bundler/bundler.git";
7
rev = "a2343c9eabf5403d8ffcbca4dea33d18a60fc157";
8
+
sha256 = "1l4r55n1wzr817l225l6pm97li1mxg9icd8s51cpfihh91nkdz68";
9
leaveDotGit = true;
10
};
11
dontPatchShebangs = true;
+15
-2
pkgs/development/interpreters/ruby/monkey_patches.rb
···
1
require 'bundler'
2
0
0
0
0
0
3
Bundler.module_eval do
4
class << self
5
# mappings from original uris to store paths.
···
21
# swap out ENV
22
def nix_with_env(env, &block)
23
if env
0
24
begin
25
-
old_env = ENV.to_h
26
ENV.replace(env)
27
block.call
28
ensure
29
-
ENV.replace old_env
30
end
31
else
32
block.call
···
131
pre_installer = "pre-installers/#{spec.name}"
132
if File.exist?(pre_installer)
133
system(pre_installer)
0
0
0
0
134
env = eval(Bundler.read_file("env/#{spec.name}"))
0
0
0
0
135
Bundler.nix_with_env(env) do
136
original_install_gem_from_spec(spec, standalone, worker)
137
end
···
1
require 'bundler'
2
3
+
# Undo the RUBYOPT trickery.
4
+
opt = ENV['RUBYOPT'].dup
5
+
opt.gsub!(/-rmonkey_patches.rb -I [^ ]*/, '')
6
+
ENV['RUBYOPT'] = opt
7
+
8
Bundler.module_eval do
9
class << self
10
# mappings from original uris to store paths.
···
26
# swap out ENV
27
def nix_with_env(env, &block)
28
if env
29
+
old_env = ENV.to_hash
30
begin
0
31
ENV.replace(env)
32
block.call
33
ensure
34
+
ENV.replace(old_env)
35
end
36
else
37
block.call
···
136
pre_installer = "pre-installers/#{spec.name}"
137
if File.exist?(pre_installer)
138
system(pre_installer)
139
+
unless $?.success?
140
+
Bundler.ui.error "The pre-installer script for #{spec.name} failed!"
141
+
exit 1
142
+
end
143
env = eval(Bundler.read_file("env/#{spec.name}"))
144
+
unless env
145
+
Bundler.ui.error "The environment variables for #{spec.name} could not be loaded!"
146
+
exit 1
147
+
end
148
Bundler.nix_with_env(env) do
149
original_install_gem_from_spec(spec, standalone, worker)
150
end