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