consule: use new bundlerEnv
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
{ stdenv, runCommand, writeText, writeScript, writeScriptBin, ruby, lib
|
||||
, callPackage , gemFixes, fetchurl, fetchgit, buildRubyGem
|
||||
, bundler_HEAD
|
||||
, callPackage, defaultGemConfig, fetchurl, fetchgit, buildRubyGem , bundler_HEAD
|
||||
, git
|
||||
}@defs:
|
||||
|
||||
# This is a work-in-progress.
|
||||
# The idea is that his will replace load-ruby-env.nix.
|
||||
|
||||
{ name, gemset, gemfile, lockfile, ruby ? defs.ruby, fixes ? gemFixes
|
||||
{ name, gemset, gemfile, lockfile, ruby ? defs.ruby, gemConfig ? defaultGemConfig
|
||||
, enableParallelBuilding ? false # TODO: this might not work, given the env-var shinanigans.
|
||||
, documentation ? false
|
||||
, meta ? {}
|
||||
@@ -37,9 +36,9 @@ let
|
||||
src = (fetchers."${attrs.source.type}" attrs);
|
||||
};
|
||||
|
||||
applyFixes = attrs:
|
||||
if fixes ? "${attrs.name}"
|
||||
then attrs // fixes."${attrs.name}" attrs
|
||||
applyGemConfigs = attrs:
|
||||
if gemConfig ? "${attrs.name}"
|
||||
then attrs // gemConfig."${attrs.name}" attrs
|
||||
else attrs;
|
||||
|
||||
needsPatch = attrs:
|
||||
@@ -118,7 +117,7 @@ let
|
||||
};
|
||||
|
||||
instantiate = (attrs:
|
||||
applyPatches (applyFixes (applySrc attrs))
|
||||
applyPatches (applyGemConfigs (applySrc attrs))
|
||||
);
|
||||
|
||||
instantiated = lib.flip lib.mapAttrs (import gemset) (name: attrs:
|
||||
@@ -236,15 +235,15 @@ let
|
||||
end
|
||||
'';
|
||||
|
||||
needsBuildArgs = attrs: attrs ? buildArgs;
|
||||
needsBuildFlags = attrs: attrs ? buildFlags;
|
||||
|
||||
mkBuildArgs = spec:
|
||||
"export BUNDLE_BUILD__${lib.toUpper spec.name}='${lib.concatStringsSep " " (map shellEscape spec.buildArgs)}'";
|
||||
mkBuildFlags = spec:
|
||||
"export BUNDLE_BUILD__${lib.toUpper spec.name}='${lib.concatStringsSep " " (map shellEscape spec.buildFlags)}'";
|
||||
|
||||
allBuildArgs =
|
||||
allBuildFlags =
|
||||
lib.concatStringsSep "\n"
|
||||
(map mkBuildArgs
|
||||
(lib.filter needsBuildArgs (attrValues instantiated)));
|
||||
(map mkBuildFlags
|
||||
(lib.filter needsBuildFlags (attrValues instantiated)));
|
||||
|
||||
in
|
||||
|
||||
@@ -266,6 +265,8 @@ stdenv.mkDerivation {
|
||||
|
||||
installPhase = ''
|
||||
# Copy the Gemfile and Gemfile.lock
|
||||
#mkdir out
|
||||
#out=$(pwd -P)/out
|
||||
|
||||
mkdir -p $bundle
|
||||
export BUNDLE_GEMFILE=$bundle/Gemfile
|
||||
@@ -285,7 +286,7 @@ stdenv.mkDerivation {
|
||||
mkdir env
|
||||
${runPreInstallers}
|
||||
|
||||
${allBuildArgs}
|
||||
${allBuildFlags}
|
||||
|
||||
${lib.optionalString (!documentation) ''
|
||||
mkdir home
|
||||
|
||||
+63
-14
@@ -18,7 +18,9 @@
|
||||
# (to make gems behave if necessary).
|
||||
|
||||
{ lib, fetchurl, writeScript, ruby, libxml2, libxslt, python, stdenv, which
|
||||
, libiconv, postgresql, v8_3_16_14, clang, sqlite, zlib, imagemagick, pkgconfig}:
|
||||
, libiconv, postgresql, v8, v8_3_16_14, clang, sqlite, zlib, imagemagick, pkgconfig
|
||||
, ncurses, xapian, gpgme, utillinux
|
||||
}:
|
||||
|
||||
let
|
||||
v8 = v8_3_16_14;
|
||||
@@ -30,9 +32,34 @@ in
|
||||
dontPatchShebangs = true;
|
||||
};
|
||||
|
||||
gpgme = attrs: {
|
||||
buildInputs = [ gpgme ];
|
||||
};
|
||||
|
||||
libv8 = attrs: {
|
||||
buildFlags = [ "--with-system-v8" ];
|
||||
buildInputs = [ which v8 python ];
|
||||
# The "--with-system-v8" flag doesn't seem to work...
|
||||
postPatch = ''
|
||||
rm -r vendor
|
||||
cp ${./location.rb} ext/libv8/location.rb
|
||||
cat <<-EOF > ext/libv8/extconf.rb
|
||||
require 'mkmf'
|
||||
create_makefile('libv8')
|
||||
|
||||
require File.expand_path '../location', __FILE__
|
||||
location = Libv8::Location::System.new
|
||||
|
||||
exit location.install!
|
||||
EOF
|
||||
'';
|
||||
};
|
||||
|
||||
ncursesw = attrs: {
|
||||
buildInputs = [ ncurses ];
|
||||
buildFlags = [
|
||||
"--with-cflags=-I${ncurses}/include"
|
||||
"--with-ldflags=-L${ncurses}/lib"
|
||||
];
|
||||
};
|
||||
|
||||
nokogiri = attrs: {
|
||||
@@ -66,24 +93,46 @@ in
|
||||
];
|
||||
};
|
||||
|
||||
sup = attrs: {
|
||||
# prevent sup from trying to dynamically install `xapian-ruby`.
|
||||
postPatch = ''
|
||||
cp ${./mkrf_conf_xapian.rb} ext/mkrf_conf_xapian.rb
|
||||
|
||||
substituteInPlace lib/sup/crypto.rb \
|
||||
--replace 'which gpg2' \
|
||||
'${which}/bin/which gpg2'
|
||||
'';
|
||||
};
|
||||
|
||||
therubyracer = attrs: {
|
||||
dontBuild = false;
|
||||
#preInstall = ''
|
||||
# ln -s ${clang}/bin/clang $TMPDIR/gcc
|
||||
# ln -s ${clang}/bin/clang++ $TMPDIR/g++
|
||||
# export PATH=$TMPDIR:$PATH
|
||||
#'';
|
||||
|
||||
preInstall = ''
|
||||
ln -s ${clang}/bin/clang $TMPDIR/gcc
|
||||
ln -s ${clang}/bin/clang++ $TMPDIR/g++
|
||||
export PATH=$TMPDIR:$PATH
|
||||
'';
|
||||
#buildInputs = [
|
||||
# utillinux # for `flock`
|
||||
#];
|
||||
|
||||
postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
|
||||
cat >> $out/nix-support/setup-hook <<EOF
|
||||
export DYLD_INSERT_LIBRARIES="$DYLD_INSERT_LIBRARIES''${!DYLD_INSERT_LIBRARIES:+:}${v8}/lib/libv8.dylib"
|
||||
EOF
|
||||
'';
|
||||
#postInstall = ''
|
||||
#'';
|
||||
|
||||
buildFlags = [
|
||||
"--with-v8-dir=${v8}" "--with-v8-include=${v8}/include"
|
||||
"--with-v8-dir=${v8}"
|
||||
"--with-v8-include=${v8}/include"
|
||||
"--with-v8-lib=${v8}/lib"
|
||||
];
|
||||
};
|
||||
|
||||
xapian-ruby = attrs: {
|
||||
# use the system xapian
|
||||
buildInputs = [ xapian pkgconfig zlib ];
|
||||
postPatch = ''
|
||||
cp ${./xapian-Rakefile} Rakefile
|
||||
'';
|
||||
preInstall = ''
|
||||
export XAPIAN_CONFIG=${xapian}/bin/xapian-config
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
# See: https://github.com/cowboyd/libv8/pull/161
|
||||
|
||||
require 'yaml'
|
||||
require 'pathname'
|
||||
require File.expand_path '../paths', __FILE__
|
||||
|
||||
module Libv8
|
||||
class Location
|
||||
def install!
|
||||
File.open(Pathname(__FILE__).dirname.join('.location.yml'), "w") do |f|
|
||||
f.write self.to_yaml
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
def self.load!
|
||||
File.open(Pathname(__FILE__).dirname.join('.location.yml')) do |f|
|
||||
YAML.load f
|
||||
end
|
||||
end
|
||||
|
||||
class Vendor < Location
|
||||
def install!
|
||||
require File.expand_path '../builder', __FILE__
|
||||
builder = Libv8::Builder.new
|
||||
exit_status = builder.build_libv8!
|
||||
super if exit_status == 0
|
||||
verify_installation!
|
||||
return exit_status
|
||||
end
|
||||
def configure(context = MkmfContext.new)
|
||||
context.incflags.insert 0, Libv8::Paths.include_paths.map{|p| "-I#{p}"}.join(" ") + " "
|
||||
context.ldflags.insert 0, Libv8::Paths.object_paths.join(" ") + " "
|
||||
end
|
||||
|
||||
def verify_installation!
|
||||
Libv8::Paths.object_paths.each do |p|
|
||||
fail ArchiveNotFound, p unless File.exist? p
|
||||
end
|
||||
end
|
||||
|
||||
class ArchiveNotFound < StandardError
|
||||
def initialize(filename)
|
||||
super "libv8 did not install properly, expected binary v8 archive '#{filename}'to exist, but it was not found"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class System < Location
|
||||
def configure(context = MkmfContext.new)
|
||||
context.send(:dir_config, 'v8')
|
||||
context.send(:find_header, 'v8.h') or fail NotFoundError
|
||||
context.send(:have_library, 'v8') or fail NotFoundError
|
||||
end
|
||||
|
||||
class NotFoundError < StandardError
|
||||
def initialize(*args)
|
||||
super(<<-EOS)
|
||||
You have chosen to use the version of V8 found on your system
|
||||
and *not* the one that is bundle with the libv8 rubygem. However,
|
||||
it could not be located. please make sure you have a version of
|
||||
v8 that is compatible with #{Libv8::VERSION} installed. You may
|
||||
need to special --with-v8-dir options if it is in a non-standard
|
||||
location
|
||||
|
||||
thanks,
|
||||
The Mgmt
|
||||
|
||||
EOS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class MkmfContext
|
||||
def incflags
|
||||
$INCFLAGS
|
||||
end
|
||||
|
||||
def ldflags
|
||||
$LDFLAGS
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
require 'rubygems'
|
||||
require 'rubygems/command.rb'
|
||||
require 'rubygems/dependency_installer.rb'
|
||||
require 'rbconfig'
|
||||
|
||||
begin
|
||||
Gem::Command.build_args = ARGV
|
||||
rescue NoMethodError
|
||||
end
|
||||
|
||||
# create dummy rakefile to indicate success
|
||||
f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w")
|
||||
f.write("task :default\n")
|
||||
f.close
|
||||
@@ -0,0 +1,38 @@
|
||||
# encoding: utf-8
|
||||
# Install the xapian binaries into the lib folder of the gem
|
||||
require 'rbconfig'
|
||||
|
||||
c = RbConfig::CONFIG
|
||||
|
||||
def system!(cmd)
|
||||
puts cmd
|
||||
system(cmd) or raise
|
||||
end
|
||||
|
||||
source_dir = 'xapian_source'
|
||||
bindings = Dir["#{source_dir}/xapian-bindings-*"].first
|
||||
bindings = File.basename(bindings, ".tar.xz")
|
||||
|
||||
task :default do
|
||||
system! "tar -xJf #{source_dir}/#{bindings}.tar.xz"
|
||||
|
||||
prefix = Dir.pwd
|
||||
ENV['LDFLAGS'] = "-L#{prefix}/lib"
|
||||
|
||||
system! "mkdir -p lib"
|
||||
|
||||
Dir.chdir bindings do
|
||||
ENV['RUBY'] ||= "#{c['bindir']}/#{c['RUBY_INSTALL_NAME']}"
|
||||
system! "./configure --prefix=#{prefix} --exec-prefix=#{prefix} --with-ruby"
|
||||
system! "make clean all"
|
||||
end
|
||||
|
||||
system! "cp -r #{bindings}/ruby/.libs/_xapian.* lib"
|
||||
system! "cp #{bindings}/ruby/xapian.rb lib"
|
||||
|
||||
system! "rm lib/*.la"
|
||||
system! "rm lib/*.lai"
|
||||
|
||||
system! "rm -R #{bindings}"
|
||||
system! "rm -R #{source_dir}"
|
||||
end
|
||||
Reference in New Issue
Block a user