Merge pull request #4677 from cstrahan/pleasant-ruby

Pleasant ruby
This commit is contained in:
Charles Strahan 2015-01-21 23:27:38 -05:00
commit 8d49e87dec
58 changed files with 1577 additions and 2932 deletions

View file

@ -618,7 +618,7 @@ sed -i '/ = data_files/d' setup.py</programlisting>
<screen>
$ nix-env -i gem-nix
$ gem-nix --no-user-install --nix-file=pkgs/development/interpreters/ruby/generated.nix yajl-ruby
$ nix-build -A rubyLibs.yajl-ruby
$ nix-build -A rubyPackages.yajl-ruby
</screen>
</section>

View file

@ -8,7 +8,6 @@ let
cfg = config.services.redmine;
ruby = pkgs.ruby;
rubyLibs = pkgs.rubyLibs;
databaseYml = ''
production:
@ -155,7 +154,7 @@ in {
environment.HOME = "${pkgs.redmine}/share/redmine";
environment.REDMINE_LANG = "en";
environment.GEM_HOME = "${pkgs.redmine}/share/redmine/vendor/bundle/ruby/1.9.1";
environment.GEM_PATH = "${rubyLibs.bundler}/lib/ruby/gems/1.9";
environment.GEM_PATH = "${bundler}/${bundler.ruby.gemPath}";
path = with pkgs; [
imagemagickBig
subversion

View file

@ -15,7 +15,7 @@ let
launcher = writeScriptBin "riemann-dash" ''
#!/bin/sh
exec ${rubyLibs.riemann_dash}/bin/riemann-dash ${conf}
exec ${pkgs.riemann-dash}/bin/riemann-dash ${conf}
'';
in {

View file

@ -0,0 +1,4 @@
---
gem:
https://rubygems.org/downloads/mini_portile-0.6.0.gem: 09kcn4g63xrdirgwxgjikqg976rr723bkc9bxfr29pk22cj3wavn
https://rubygems.org/downloads/gpgme-2.0.7.gem: 1p84zhiri2ihcld7py9mwc2kg5xs5da8fk11zhndrhmw05yvf5mr

View file

@ -0,0 +1,8 @@
source "https://rubygems.org"
gem 'sup'
gem 'gpgme'
# Sup tries to `xapian-ruby` in its extconf instead of listing it as a
# dependency.
gem 'xapian-ruby', "~> 1.2.15"

View file

@ -0,0 +1,34 @@
GEM
remote: https://rubygems.org/
specs:
chronic (0.9.1)
gpgme (2.0.7)
mini_portile (>= 0.5.0, <= 0.6.0)
highline (1.6.21)
locale (2.1.0)
lockfile (2.1.3)
mime-types (1.25.1)
mini_portile (0.6.0)
ncursesw (1.4.9)
rmail-sup (1.0.1)
sup (0.20.0)
chronic (~> 0.9.1)
highline
locale (~> 2.0)
lockfile
mime-types (~> 1.0)
ncursesw (~> 1.4.0)
rmail-sup (~> 1.0.1)
trollop (>= 1.12)
unicode (~> 0.4.4)
trollop (2.1.1)
unicode (0.4.4.2)
xapian-ruby (1.2.19.1)
PLATFORMS
ruby
DEPENDENCIES
gpgme
sup
xapian-ruby (~> 1.2.15)

View file

@ -1,79 +1,19 @@
{ stdenv, fetchurl, ruby, rake, rubygems, makeWrapper, ncursesw_sup
, xapian_ruby, gpgme, libiconvOrEmpty, mime_types, chronic, trollop, lockfile
, gettext, iconv, locale, text, highline, rmail_sup, unicode, gnupg, which
, bundler, git }:
{ stdenv, lib, bundlerEnv, gpgme, ruby, ncurses, writeText, zlib, xapian
, pkgconfig, which }:
stdenv.mkDerivation rec {
version = "0.18.0";
name = "sup-${version}";
bundlerEnv {
name = "sup-0.20.0";
meta = {
inherit ruby;
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
gemset = ./gemset.nix;
meta = with lib; {
description = "A curses threads-with-tags style email client";
homepage = http://supmua.org;
license = stdenv.lib.licenses.gpl2;
maintainers = with stdenv.lib.maintainers; [ lovek323 ];
platforms = stdenv.lib.platforms.unix;
broken = true;
license = with licenses; gpl2;
maintainers = with maintainers; [ cstrahan lovek323 ];
platforms = platforms.unix;
};
dontStrip = true;
src = fetchurl {
url = "https://github.com/sup-heliotrope/sup/archive/release-${version}.tar.gz";
sha256 = "1dhg0i2v0ddhwi32ih5lc56x00kbaikd2wdplgzlshq0nljr9xy0";
};
buildInputs =
[ rake ruby rubygems makeWrapper gpgme ncursesw_sup xapian_ruby
libiconvOrEmpty git ];
phases = [ "unpackPhase" "buildPhase" "installPhase" ];
buildPhase = ''
# the builder uses git to get a listing of the files
export EMAIL="nobody@in.here"
git init >/dev/null
git add .
git commit -m "message" >/dev/null
gem build sup.gemspec
'';
installPhase = ''
export HOME=$TMP/home; mkdir -pv "$HOME"
GEM_PATH="$GEM_PATH:$out/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${chronic}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${gettext}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${gpgme}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${highline}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${iconv}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${locale}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${lockfile}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${mime_types}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${ncursesw_sup}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${rmail_sup}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${text}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${trollop}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${unicode}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${xapian_ruby}/${ruby.gemPath}"
# Don't install some dependencies -- we have already installed
# the dependencies but gem doesn't acknowledge this
gem install --no-verbose --install-dir "$out/${ruby.gemPath}" \
--bindir "$out/bin" --no-rdoc --no-ri sup-${version}.gem \
--ignore-dependencies >/dev/null
# specify ruby interpreter explicitly
sed -i '1 s|^.*$|#!${ruby}/bin/ruby|' bin/sup-sync-back-maildir
cp bin/sup-sync-back-maildir "$out/bin"
for prog in $out/bin/*; do
wrapProgram "$prog" --prefix GEM_PATH : "$GEM_PATH" --prefix PATH : "${gnupg}/bin:${which}/bin"
done
for prog in $out/gems/*/bin/*; do
[[ -e "$out/bin/$(basename $prog)" ]]
done
'';
}

View file

@ -0,0 +1,107 @@
{
"chronic" = {
version = "0.9.1";
source = {
type = "gem";
sha256 = "0kspaxpfy7yvyk1lvpx31w852qfj8wb9z04mcj5bzi70ljb9awqk";
};
};
"gpgme" = {
version = "2.0.7";
source = {
type = "gem";
sha256 = "1p84zhiri2ihcld7py9mwc2kg5xs5da8fk11zhndrhmw05yvf5mr";
};
dependencies = [
"mini_portile"
];
};
"highline" = {
version = "1.6.21";
source = {
type = "gem";
sha256 = "06bml1fjsnrhd956wqq5k3w8cyd09rv1vixdpa3zzkl6xs72jdn1";
};
};
"locale" = {
version = "2.1.0";
source = {
type = "gem";
sha256 = "18bb0g24flq9dr8qv4j7pm7w9i2vmvmqrbmry95ibf1r1c4s60yj";
};
};
"lockfile" = {
version = "2.1.3";
source = {
type = "gem";
sha256 = "0dij3ijywylvfgrpi2i0k17f6w0wjhnjjw0k9030f54z56cz7jrr";
};
};
"mime-types" = {
version = "1.25.1";
source = {
type = "gem";
sha256 = "0mhzsanmnzdshaba7gmsjwnv168r1yj8y0flzw88frw1cickrvw8";
};
};
"mini_portile" = {
version = "0.6.0";
source = {
type = "gem";
sha256 = "09kcn4g63xrdirgwxgjikqg976rr723bkc9bxfr29pk22cj3wavn";
};
};
"ncursesw" = {
version = "1.4.9";
source = {
type = "gem";
sha256 = "154cls3b237imdbhih7rni5p85nw6mpbpkzdw08jxzvqaml7q093";
};
};
"rmail-sup" = {
version = "1.0.1";
source = {
type = "gem";
sha256 = "1xswk101s560lxqaax3plqh8vjx7jjspnggdwb3q80m358f92q9g";
};
};
"sup" = {
version = "0.20.0";
source = {
type = "gem";
sha256 = "1lpqgrqkv29xr1h1142qsbmknlshpgys7fc3w1nkyhib8s3ikamg";
};
dependencies = [
"chronic"
"highline"
"locale"
"lockfile"
"mime-types"
"ncursesw"
"rmail-sup"
"trollop"
"unicode"
];
};
"trollop" = {
version = "2.1.1";
source = {
type = "gem";
sha256 = "0z5dvh7glwqjprlihsjx67hfzy4whsjfhqj9akyyrby9q5va1i4k";
};
};
"unicode" = {
version = "0.4.4.2";
source = {
type = "gem";
sha256 = "15fggljzan8zvmr8h12b5m7pcj1gvskmmnx367xs4p0rrpnpil8g";
};
};
"xapian-ruby" = {
version = "1.2.19.1";
source = {
type = "gem";
sha256 = "1crfrmc8kf6qq1xcfcmgf213zg66badpg4d86n7y9x3i1f5lxlbv";
};
};
}

View file

@ -10,7 +10,6 @@ stdenv.mkDerivation rec {
sha256 = "1f6r8vlwnmqmr85drfv24vhqx1aacz6s83c2i804v9997n0wrwfm";
};
buildInputs = [ go ];
phases = [ "unpackPhase" "buildPhase" "installPhase" ];
@ -37,7 +36,6 @@ stdenv.mkDerivation rec {
# ?
'';
meta = with stdenv.lib; {
description = "Command-line wrapper for git that makes you better at GitHub";

View file

@ -14,7 +14,7 @@ in stdenv.mkDerivation rec {
sha256 = "0x0zwxyj4dwbk7l64s3lgny10mjf0ba8jwrbafsm4d72sncmacv0";
};
buildInputs = [
ruby rubyLibs.bundler libiconv libxslt libxml2 pkgconfig
ruby bundler libiconv libxslt libxml2 pkgconfig
libffi imagemagickBig postgresql which stdenv
];
installPhase = ''

View file

@ -1,4 +1,4 @@
{ stdenv, fetchurl, ruby, rubyLibs, libiconv, libiconvOrNull, libiconvOrLibc, libxslt, libxml2, pkgconfig, libffi, glibc, imagemagickBig, postgresql }:
{ stdenv, fetchurl, ruby, bundler, libiconv, libiconvOrNull, libiconvOrLibc, libxslt, libxml2, pkgconfig, libffi, glibc, imagemagickBig, postgresql }:
let
gemspec = map (gem: fetchurl { url=gem.url; sha256=gem.hash; }) (import ./Gemfile.nix);
@ -25,7 +25,7 @@ in stdenv.mkDerivation rec {
'';
buildInputs = [
ruby rubyLibs.bundler
ruby bundler
] ++ (if (libiconvOrNull != null) then [libiconv] else []) ++ [
libxslt libxml2 pkgconfig libffi
imagemagickBig postgresql

View file

@ -0,0 +1,4 @@
source "http://rubygems.org"
gem "bundix",
:git => "https://github.com/cstrahan/bundix.git",
:ref => "5df25b11b5b86e636754d54c2a8859c7c6ec78c7"

View file

@ -0,0 +1,19 @@
GIT
remote: https://github.com/cstrahan/bundix.git
revision: 5df25b11b5b86e636754d54c2a8859c7c6ec78c7
ref: 5df25b11b5b86e636754d54c2a8859c7c6ec78c7
specs:
bundix (0.1.0)
bundler (~> 1.7.9)
thor (~> 0.19.1)
GEM
remote: http://rubygems.org/
specs:
thor (0.19.1)
PLATFORMS
ruby
DEPENDENCIES
bundix!

View file

@ -0,0 +1,9 @@
{ ruby, bundlerEnv }:
bundlerEnv {
name = "bundix";
inherit ruby;
gemset = ./gemset.nix;
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
}

View file

@ -0,0 +1,22 @@
{
"bundix" = {
version = "0.1.0";
source = {
type = "git";
url = "https://github.com/cstrahan/bundix.git";
rev = "5df25b11b5b86e636754d54c2a8859c7c6ec78c7";
fetchSubmodules = false;
sha256 = "0334jsavpzkikcs7wrx7a3r0ilvr5vsnqd34lhc58b8cgvgll47p";
};
dependencies = [
"thor"
];
};
"thor" = {
version = "0.19.1";
source = {
type = "gem";
sha256 = "08p5gx18yrbnwc6xc0mxvsfaxzgy2y9i78xq7ds0qmdm67q39y4z";
};
};
}

View file

@ -0,0 +1,115 @@
# The standard set of gems in nixpkgs including potential fixes.
#
# The gemset is derived from two points of entry:
# - An attrset describing a gem, including version, source and dependencies
# This is just meta data, most probably automatically generated by a tool
# like Bundix (https://github.com/aflatter/bundix).
# {
# name = "bundler";
# version = "1.6.5";
# sha256 = "1s4x0f5by9xs2y24jk6krq5ky7ffkzmxgr4z1nhdykdmpsi2zd0l";
# dependencies = [ "rake" ];
# }
# - An optional derivation that may override how the gem is built. For popular
# gems that don't behave correctly, fixes are already provided in the form of
# derivations.
#
# This seperates "what to build" (the exact gem versions) from "how to build"
# (to make gems behave if necessary).
{ lib, fetchurl, writeScript, ruby, libxml2, libxslt, python, stdenv, which
, libiconv, postgresql, v8, v8_3_16_14, clang, sqlite, zlib, imagemagick, pkgconfig
, ncurses, xapian, gpgme, utillinux, fetchpatch
}:
let
v8 = v8_3_16_14;
in
{
gpgme = attrs: {
buildInputs = [ gpgme ];
};
libv8 = attrs: {
buildInputs = [ which v8 python ];
buildFlags = [
"--with-system-v8=true"
];
patches = [
(fetchpatch {
url = https://github.com/cowboyd/libv8/pull/161.patch;
sha256 = "1l6572cmigc22g249jj8h0xlbig88mj43kdqdbimhw2pmpv3q0rs";
})
];
};
ncursesw = attrs: {
buildInputs = [ ncurses ];
buildFlags = [
"--with-cflags=-I${ncurses}/include"
"--with-ldflags=-L${ncurses}/lib"
];
};
nokogiri = attrs: {
buildFlags = [
"--use-system-libraries"
"--with-zlib-dir=${zlib}"
"--with-xml2-lib=${libxml2}/lib"
"--with-xml2-include=${libxml2}/include/libxml2"
"--with-xslt-lib=${libxslt}/lib"
"--with-xslt-include=${libxslt}/include"
"--with-exslt-lib=${libxslt}/lib"
"--with-exslt-include=${libxslt}/include"
] ++ lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
};
pg = attrs: {
buildFlags = [
"--with-pg-config=${postgresql}/bin/pg_config"
];
};
rmagick = attrs: {
buildInputs = [ imagemagick pkgconfig ];
};
sqlite3 = attrs: {
buildFlags = [
"--with-sqlite3-include=${sqlite}/include"
"--with-sqlite3-lib=${sqlite}/lib"
];
};
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: {
buildFlags = [
"--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
'';
};
}

View file

@ -0,0 +1,306 @@
{ stdenv, runCommand, writeText, writeScript, writeScriptBin, ruby, lib
, 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, gemConfig ? defaultGemConfig
, enableParallelBuilding ? false # TODO: this might not work, given the env-var shinanigans.
, documentation ? false
, meta ? {}
}@args:
let
shellEscape = x: "'${lib.replaceChars ["'"] [("'\\'" + "'")] x}'";
const = x: y: x;
bundler = bundler_HEAD.override { inherit ruby; };
inherit (builtins) attrValues;
gemName = attrs: "${attrs.name}-${attrs.version}.gem";
fetchers.path = attrs: attrs.source.path;
fetchers.gem = attrs: fetchurl {
url = "${attrs.source.source or "https://rubygems.org"}/downloads/${gemName attrs}";
inherit (attrs.source) sha256;
};
fetchers.git = attrs: fetchgit {
inherit (attrs.source) url rev sha256 fetchSubmodules;
leaveDotGit = true;
};
applySrc = attrs:
attrs // {
src = (fetchers."${attrs.source.type}" attrs);
};
applyGemConfigs = attrs:
if gemConfig ? "${attrs.name}"
then attrs // gemConfig."${attrs.name}" attrs
else attrs;
needsPatch = attrs:
(attrs ? patches) || (attrs ? prePatch) || (attrs ? postPatch);
# patch a gem or source tree.
# for gems, the gem is unpacked, patched, and then repacked.
# see: https://github.com/fedora-ruby/gem-patch/blob/master/lib/rubygems/patcher.rb
applyPatches = attrs:
if !needsPatch attrs
then attrs
else attrs // { src =
stdenv.mkDerivation {
name = gemName attrs;
phases = [ "unpackPhase" "patchPhase" "installPhase" ];
buildInputs = [ ruby ] ++ attrs.buildInputs or [];
patches = attrs.patches or [ ];
prePatch = attrs.prePatch or "true";
postPatch = attrs.postPatch or "true";
unpackPhase = ''
runHook preUnpack
if [[ -f ${attrs.src} ]]; then
isGem=1
# we won't know the name of the directory that RubyGems creates,
# so we'll just use a glob to find it and move it over.
gem unpack ${attrs.src} --target=container
cp -r container/* contents
rm -r container
else
cp -r ${attrs.src} contents
chmod -R +w contents
fi
cd contents
runHook postUnpack
'';
installPhase = ''
runHook preInstall
if [[ -n "$isGem" ]]; then
${writeScript "repack.rb" ''
#!${ruby}/bin/ruby
require 'rubygems'
require 'rubygems/package'
require 'fileutils'
if defined?(Encoding.default_internal)
Encoding.default_internal = Encoding::UTF_8
Encoding.default_external = Encoding::UTF_8
end
if Gem::VERSION < '2.0'
load "${./package-1.8.rb}"
end
out = ENV['out']
files = Dir['**/{.[^\.]*,*}']
package = Gem::Package.new("${attrs.src}")
patched_package = Gem::Package.new(package.spec.file_name)
patched_package.spec = package.spec.clone
patched_package.spec.files = files
patched_package.build(false)
FileUtils.cp(patched_package.spec.file_name, out)
''}
else
cp -r . out
fi
runHook postInstall
'';
};
};
instantiate = (attrs:
applyPatches (applyGemConfigs (applySrc attrs))
);
instantiated = lib.flip lib.mapAttrs (import gemset) (name: attrs:
instantiate (attrs // { inherit name; })
);
needsPreInstall = attrs:
(attrs ? preInstall) || (attrs ? buildInputs) || (attrs ? nativeBuildInputs);
# TODO: support cross compilation? look at stdenv/generic/default.nix.
runPreInstallers = lib.fold (next: acc:
if !needsPreInstall next
then acc
else acc + ''
${writeScript "${next.name}-pre-install" ''
#!${stdenv.shell}
export nativeBuildInputs="${toString ((next.nativeBuildInputs or []) ++ (next.buildInputs or []))}"
source ${stdenv}/setup
header "running pre-install script for ${next.name}"
${next.preInstall or ""}
${ruby}/bin/ruby -e 'print ENV.inspect' > env/${next.name}
stopNest
''}
''
) "" (attrValues instantiated);
# copy *.gem to ./gems
copyGems = lib.fold (next: acc:
if next.source.type == "gem"
then acc + "cp ${next.src} gems/${gemName next}\n"
else acc
) "" (attrValues instantiated);
runRuby = name: env: command:
runCommand name env ''
${ruby}/bin/ruby ${writeText name command}
'';
# TODO: include json_pure, so the version of ruby doesn't matter.
# not all rubies have support for JSON built-in,
# so we'll convert JSON to ruby expressions.
json2rb = writeScript "json2rb" ''
#!${ruby}/bin/ruby
begin
require 'json'
rescue LoadError => ex
require 'json_pure'
end
puts JSON.parse(STDIN.read).inspect
'';
# dump the instantiated gemset as a ruby expression.
serializedGemset = runCommand "gemset.rb" { json = builtins.toJSON instantiated; } ''
printf '%s' "$json" | ${json2rb} > $out
'';
# this is a mapping from a source type and identifier (uri/path/etc)
# to the pure store path.
# we'll use this from the patched bundler to make fetching sources pure.
sources = runRuby "sources.rb" { gemset = serializedGemset; } ''
out = ENV['out']
gemset = eval(File.read(ENV['gemset']))
sources = {
"git" => { },
"path" => { },
"gem" => { },
"svn" => { }
}
gemset.each_value do |spec|
type = spec["source"]["type"]
val = spec["src"]
key =
case type
when "gem"
spec["name"]
when "git"
spec["source"]["url"]
when "path"
spec["source"]["originalPath"]
when "svn"
nil # TODO
end
sources[type][key] = val if key
end
File.open(out, "wb") do |f|
f.print sources.inspect
end
'';
# rewrite PATH sources to point into the nix store.
purifiedLockfile = runRuby "purifiedLockfile" {} ''
out = ENV['out']
sources = eval(File.read("${sources}"))
paths = sources["path"]
lockfile = File.read("${lockfile}")
paths.each_pair do |impure, pure|
lockfile.gsub!(/^ remote: #{Regexp.escape(impure)}/, " remote: #{pure}")
end
File.open(out, "wb") do |f|
f.print lockfile
end
'';
needsBuildFlags = attrs: attrs ? buildFlags;
mkBuildFlags = spec:
"export BUNDLE_BUILD__${lib.toUpper spec.name}='${lib.concatStringsSep " " (map shellEscape spec.buildFlags)}'";
allBuildFlags =
lib.concatStringsSep "\n"
(map mkBuildFlags
(lib.filter needsBuildFlags (attrValues instantiated)));
in
stdenv.mkDerivation {
inherit name;
buildInputs = [
ruby
bundler
git
];
phases = [ "installPhase" "fixupPhase" ];
outputs = [
"out" # the installed libs/bins
"bundle" # supporting files for bundler
];
installPhase = ''
mkdir -p $bundle
export BUNDLE_GEMFILE=$bundle/Gemfile
cp ${gemfile} $BUNDLE_GEMFILE
cp ${purifiedLockfile} $BUNDLE_GEMFILE.lock
export NIX_GEM_SOURCES=${sources}
export NIX_BUNDLER_GEMPATH=${bundler}/${ruby.gemPath}
export GEM_HOME=$out/${ruby.gemPath}
export GEM_PATH=$GEM_HOME
mkdir -p $GEM_HOME
${allBuildFlags}
#export
mkdir gems
${copyGems}
${lib.optionalString (!documentation) ''
mkdir home
HOME="$(pwd -P)/home"
echo "gem: --no-rdoc --no-ri" > $HOME/.gemrc
''}
mkdir env
${runPreInstallers}
mkdir $out/bin
cp ${./monkey_patches.rb} monkey_patches.rb
export RUBYOPT="-rmonkey_patches.rb -I $(pwd -P)"
bundler install --frozen --binstubs ${lib.optionalString enableParallelBuilding "--jobs $NIX_BUILD_CORES"}
'';
passthru = {
inherit ruby;
inherit bundler;
};
inherit meta;
}

View file

@ -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

View file

@ -0,0 +1,238 @@
require 'bundler'
# Undo the RUBYOPT trickery.
opt = ENV['RUBYOPT'].dup
opt.gsub!(/-rmonkey_patches.rb -I [^ ]*/, '')
ENV['RUBYOPT'] = opt
Bundler.module_eval do
class << self
# mappings from original uris to store paths.
def nix_gem_sources
@nix_gem_sources ||=
begin
src = ENV['NIX_GEM_SOURCES']
eval(Bundler.read_file(src))
end
end
# extract the gemspecs from the gems pulled from Rubygems.
def nix_gemspecs
@nix_gemspecs ||= Dir.glob("gems/*.gem").map do |path|
Bundler.rubygems.spec_from_gem(path)
end
end
# swap out ENV
def nix_with_env(env, &block)
if env
old_env = ENV.to_hash
begin
ENV.replace(env)
block.call
ensure
ENV.replace(old_env)
end
else
block.call
end
end
# map a git uri to a fetchgit store path.
def nix_git(uri)
Pathname.new(nix_gem_sources["git"][uri])
end
end
end
Bundler::Source::Git::GitProxy.class_eval do
def checkout
unless path.exist?
FileUtils.mkdir_p(path.dirname)
FileUtils.cp_r(Bundler.nix_git(@uri).join(".git"), path)
system("chmod -R +w #{path}")
end
end
def copy_to(destination, submodules=false)
unless File.exist?(destination.join(".git"))
FileUtils.mkdir_p(destination.dirname)
FileUtils.cp_r(Bundler.nix_git(@uri), destination)
system("chmod -R +w #{destination}")
end
end
end
Bundler::Fetcher.class_eval do
def use_api
true
end
def fetch_dependency_remote_specs(gem_names)
Bundler.ui.debug "Query Gemcutter Dependency Endpoint API: #{gem_names.join(',')}"
deps_list = []
spec_list = gem_names.map do |name|
spec = Bundler.nix_gemspecs.detect {|spec| spec.name == name }
dependencies = spec.dependencies.
select {|dep| dep.type != :development}.
map do |dep|
deps_list << dep.name
dep
end
[spec.name, spec.version, spec.platform, dependencies]
end
[spec_list, deps_list.uniq]
end
end
Bundler::Source::Rubygems.class_eval do
# We copy all gems into $PWD/gems, and this allows RubyGems to find those
# gems during installation.
def fetchers
@fetchers ||= [
Bundler::Fetcher.new(URI.parse("file://#{File.expand_path(Dir.pwd)}"))
]
end
# Look-up gems that were originally from RubyGems.
def remote_specs
@remote_specs ||=
begin
lockfile = Bundler::LockfileParser.new(Bundler.read_file(Bundler.default_lockfile))
gem_names = lockfile.specs.
select {|spec| spec.source.is_a?(Bundler::Source::Rubygems)}.
map {|spec| spec.name}
idx = Bundler::Index.new
api_fetchers.each do |f|
Bundler.ui.info "Fetching source index from #{f.uri}"
idx.use f.specs(gem_names, self)
end
idx
end
end
end
Bundler::Installer.class_eval do
# WHY:
# This allows us to provide a typical Nix experience, where
# `buildInputs` and/or `preInstall` may set up the $PATH and other env-vars
# as needed. By swapping out the environment per install, we can have finer
# grained control than we would have otherwise.
#
# HOW:
# This is a wrapper around the original `install_gem_from_spec`.
# We expect that a "pre-installer" might exist at `pre-installers/<gem-name>`,
# and if it does, we execute it.
# The pre-installer is expected to dump its environment variables as a Ruby
# hash to `env/<gem-name>`.
# We then swap out the environment for the duration of the install,
# and then set it back to what it was originally.
alias original_install_gem_from_spec install_gem_from_spec
def install_gem_from_spec(spec, standalone = false, worker = 0)
env_dump = "env/#{spec.name}"
if File.exist?(env_dump)
env = eval(Bundler.read_file(env_dump))
unless env
Bundler.ui.error "The environment variables for #{spec.name} could not be loaded!"
exit 1
end
Bundler.nix_with_env(env) do
original_install_gem_from_spec(spec, standalone, worker)
end
else
original_install_gem_from_spec(spec, standalone, worker)
end
end
def generate_bundler_executable_stubs(spec, options = {})
return if spec.executables.empty?
out = ENV['out']
spec.executables.each do |executable|
next if executable == "bundle" || executable == "bundler"
binstub_path = "#{out}/bin/#{executable}"
File.open(binstub_path, 'w', 0777 & ~File.umask) do |f|
f.print <<-TEXT
#!/usr/bin/env #{RbConfig::CONFIG['ruby_install_name']}
old_gemfile = ENV["BUNDLE_GEMFILE"]
old_gem_home = ENV["GEM_HOME"]
old_gem_path = ENV["GEM_PATH"]
ENV["BUNDLE_GEMFILE"] =
"#{ENV["BUNDLE_GEMFILE"]}"
ENV["GEM_HOME"] =
"#{ENV["GEM_HOME"]}"
ENV["GEM_PATH"] =
"#{ENV["NIX_BUNDLER_GEMPATH"]}:\#{ENV["GEM_HOME"]}\#{old_gem_path ? ":\#{old_gem_path}" : ""}}"
require 'rubygems'
require 'bundler/setup'
ENV["BUNDLE_GEMFILE"] = old_gemfile
ENV["GEM_HOME"] = old_gem_home
ENV["GEM_PATH"] = old_gem_path
load Gem.bin_path('#{spec.name}', '#{executable}')
TEXT
end
end
end
end
Gem::Installer.class_eval do
# Make the wrappers automagically use bundler.
#
# Stage 1.
# Set $BUNDLE_GEMFILE so bundler knows what gems to load.
# Set $GEM_HOME to the installed gems, because bundler looks there for
# non-Rubygems installed gems (e.g. git/svn/path sources).
# Set $GEM_PATH to include both bundler and installed gems.
#
# Stage 2.
# Setup bundler, locking down the gem versions.
#
# Stage 3.
# Reset $BUNDLE_GEMFILE, $GEM_HOME, $GEM_PATH.
#
# Stage 4.
# Run the actual executable.
def app_script_text(bin_file_name)
return <<-TEXT
#{shebang bin_file_name}
#
# This file was generated by Nix's RubyGems.
#
# The application '#{spec.name}' is installed as part of a gem, and
# this file is here to facilitate running it.
#
old_gemfile = ENV["BUNDLE_GEMFILE"]
old_gem_home = ENV["GEM_HOME"]
old_gem_path = ENV["GEM_PATH"]
ENV["BUNDLE_GEMFILE"] =
"#{ENV["BUNDLE_GEMFILE"]}"
ENV["GEM_HOME"] =
"#{ENV["GEM_HOME"]}"
ENV["GEM_PATH"] =
"#{ENV["NIX_BUNDLER_GEMPATH"]}:\#{ENV["GEM_HOME"]}\#{old_gem_path ? ":\#{old_gem_path}" : ""}}"
require 'rubygems'
require 'bundler/setup'
ENV["BUNDLE_GEMFILE"] = old_gemfile
ENV["GEM_HOME"] = old_gem_home
ENV["GEM_PATH"] = old_gem_path
load Gem.bin_path('#{spec.name}', '#{bin_file_name}')
TEXT
end
end

View file

@ -0,0 +1,29 @@
require 'rubygems/installer'
require 'rubygems/builder'
# Simulate RubyGems 2.0 behavior.
module Gem::Package
def self.new(gem)
@gem = gem
self
end
def self.extract_files(dir)
installer = Gem::Installer.new @gem
installer.unpack(dir)
end
def self.build(skip_validation=false)
builder = Gem::Builder.new(spec)
builder.build
end
def self.spec=(spec)
@spec = spec
end
def self.spec
@spec ||= Gem::Installer.new(@gem).spec
end
end

View file

@ -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

View file

@ -0,0 +1,18 @@
{ buildRubyGem, coreutils, fetchgit }:
buildRubyGem {
name = "bundler-HEAD";
src = fetchgit {
url = "https://github.com/bundler/bundler.git";
rev = "a2343c9eabf5403d8ffcbca4dea33d18a60fc157";
sha256 = "1l4r55n1wzr817l225l6pm97li1mxg9icd8s51cpfihh91nkdz68";
leaveDotGit = true;
};
dontPatchShebangs = true;
postInstall = ''
find $out -type f -perm +0100 | while read f; do
substituteInPlace $f \
--replace "/usr/bin/env" "${coreutils}/bin/env"
done
'';
}

View file

@ -0,0 +1,13 @@
{ buildRubyGem, coreutils }:
buildRubyGem {
name = "bundler-1.7.9";
sha256 = "1gd201rh17xykab9pbqp0dkxfm7b9jri02llyvmrc0c5bz2vhycm";
dontPatchShebangs = true;
postInstall = ''
find $out -type f -perm +0100 | while read f; do
substituteInPlace $f \
--replace "/usr/bin/env" "${coreutils}/bin/env"
done
'';
}

View file

@ -1,35 +0,0 @@
diff --git a/lib/nix/gem-nix-command.rb b/lib/nix/gem-nix-command.rb
index 8d3733e..ba942ff 100644
--- a/lib/nix/gem-nix-command.rb
+++ b/lib/nix/gem-nix-command.rb
@@ -108,11 +108,12 @@ class Gem::Commands::NixCommand < Gem::Command
# args to dep informations
args.each { |arg|
- if arg =~ /(.+)-?(.*)?/ then
+ if arg =~ /(.+)-([0-9][^-]+)/ then
gem_name = $1
- version = $2.empty? ? Gem::Requirement.default : Gem::Version.new($2)
+ version = Gem::Version.new($2)
else
- raise Gem::CommandLineError, "couldn't parse arg. expected: name or name-version"
+ gem_name = arg
+ version = Gem::Requirement.default
end
adddep(Gem::Dependency.new gem_name, version)
@@ -162,7 +163,13 @@ class Gem::Commands::NixCommand < Gem::Command
spec, source_uri = find_gem_with_source(dep)
full_name = spec.full_name
- return if @gems_with_deps.key?(full_name)
+ if @gems_with_deps.key?(full_name)
+ unless @gems_with_deps[full_name].nil?
+ return @gems_with_deps[full_name][0]
+ else
+ return nil
+ end
+ end
@gems_with_deps[full_name] = nil # there maybe circular dependencies. thus mark this gem seen as early as possible
# development deps can't be found. Some are old. Thus only add rutime dependencies

View file

@ -1,63 +1,136 @@
{stdenv, fetchurl, ruby, rubygems, makeWrapper, patches, overrides}:
{ lib, ruby, rubygemsFun, fetchurl, makeWrapper, git } @ defs:
let
gemDefaults = { name, basename, requiredGems, sha256, meta }:
{
buildInputs = [rubygems makeWrapper];
unpackPhase = ":";
configurePhase=":";
bulidPhase=":";
lib.makeOverridable (
src = fetchurl {
url = "http://rubygems.org/downloads/${name}.gem";
inherit sha256;
{ name
, ruby ? defs.ruby
, rubygems ? (rubygemsFun ruby)
, stdenv ? ruby.stdenv
, namePrefix ? "${ruby.name}" + "-"
, buildInputs ? []
, doCheck ? false
, dontBuild ? true
, meta ? {}
, gemPath ? []
, ...} @ attrs:
stdenv.mkDerivation (attrs // {
inherit ruby rubygems;
inherit doCheck;
buildInputs = [ ruby rubygems makeWrapper git ] ++ buildInputs;
name = namePrefix + name;
src = if attrs ? src
then attrs.src
else fetchurl {
url = "http://rubygems.org/downloads/${attrs.name}.gem";
inherit (attrs) sha256;
};
name = "ruby-${name}";
phases = [ "unpackPhase" "patchPhase" "buildPhase" "checkPhase" "installPhase" "fixupPhase" ];
propagatedBuildInputs = requiredGems ++ [ruby];
# The source is expected to either be a gem package or a directory.
#
# - Gem packages are already built, so they don't even need to be unpacked.
# They will skip the buildPhase.
# - A directory containing the sources will need to go through all of the
# usual phases.
unpackPhase= ''
gemRegex="\.gem"
if [[ $src =~ $gemRegex ]]
then
runHook preUnpack
echo "source is a gem package, won't unpack"
gempkg=$src
dontBuild=1
runHook postUnpack
else
# Fall back to the original thing for everything else.
unpackPhase
fi
'';
inherit meta;
checkPhase = "true";
installPhase = ''
export HOME=$TMP/home; mkdir -pv "$HOME"
buildPhase = ''
runHook preBuild
gem install -V --ignore-dependencies \
-i "$out/${ruby.gemPath}" -n "$out/bin" "$src" $gemFlags -- $buildFlags
rm -frv $out/${ruby.gemPath}/cache # don't keep the .gem file here
# TODO: Investigate. The complete working tree is touched by fetchgit.
if [ -d .git ]; then
git reset
fi
gemspec=$(find . -name '*.gemspec')
echo "found the following gemspecs:"
echo "$gemspec"
gemspec=$(echo "$gemspec" | head -n1)
echo "building $gemspec"
exec 3>&1
output=$(gem build $gemspec | tee >(cat - >&3))
exec 3>&-
gempkg=$(echo "$output" | grep -oP 'File: \K(.*)')
echo "gem package built: $gempkg"
runHook postBuild
'';
installPhase = ''
runHook preInstall
# NOTE: This does NOT build the unpacked gem, but installs $src directly.
# Gems that have not been downloaded from rubygems.org may need a
# separate buildPhase.
# --ignore-dependencies is necessary as rubygems otherwise always
# connects to the repository, thus breaking pure builds.
GEM_HOME=$out/${ruby.gemPath} \
gem install \
--local \
--force \
--http-proxy "http://nodtd.invalid" \
--ignore-dependencies \
--build-root "/" \
--backtrace \
$gempkg $gemFlags -- $buildFlags
# Yes, we really do need the $out/${ruby.gemPath}/cache.
# This is very important in order for many parts of RubyGems/Bundler to not blow up.
# See https://github.com/bundler/bundler/issues/3327
mkdir -p $out/bin
for prog in $out/${ruby.gemPath}/gems/*/bin/*; do
makeWrapper $prog $out/bin/$(basename $prog) \
--prefix GEM_PATH : "$out/${ruby.gemPath}:$GEM_PATH" \
--prefix RUBYLIB : "${rubygems}/lib" \
$extraWrapperFlags ''${extraWrapperFlagsArray[@]}
done
#--prefix RUBYOPT rubygems \
# looks like useless files which break build repeatability and consume space
rm -fv $out/${ruby.gemPath}/doc/*/*/created.rid || true
rm -fv $out/${ruby.gemPath}/gems/*/ext/*/mkmf.log || true
mkdir -p $out/nix-support
cat > $out/nix-support/setup-hook <<EOF
if [[ "\$GEM_PATH" != *$out* ]]; then
addToSearchPath GEM_PATH $out/${ruby.gemPath}
fi
EOF
for prog in $out/bin/*; do
wrapProgram "$prog" \
--prefix GEM_PATH : "$GEM_PATH" \
--prefix RUBYLIB : "${rubygems}/lib" \
--set RUBYOPT rubygems \
$extraWrapperFlags ''${extraWrapperFlagsArray[@]}
done
runHook postInstall
'';
for prog in $out/gems/*/bin/*; do
[[ -e "$out/bin/$(basename $prog)" ]]
done
propagatedBuildInputs = gemPath;
propagatedUserEnvPkgs = gemPath;
# looks like useless files which break build repeatability and consume space
rm $out/${ruby.gemPath}/doc/*/*/created.rid || true
rm $out/${ruby.gemPath}/gems/*/ext/*/mkmf.log || true
passthru.isRubyGem = true;
inherit meta;
})
runHook postInstall
'';
propagatedUserEnvPkgs = requiredGems;
passthru.isRubyGem = true;
};
mb = stdenv.lib.maybeAttr;
patchedGem = a: stdenv.mkDerivation (removeAttrs (stdenv.lib.mergeAttrsByFuncDefaults
([ (gemDefaults a) ]
++ (stdenv.lib.concatMap (p: [(mb a.basename {} p) (mb a.name {} p)] )
patches)))
[ "mergeAttrBy" ]);
in
aName: a@{ name, basename, requiredGems, sha256, meta }:
stdenv.lib.foldl (d: o: mb name (mb basename d o) o) (patchedGem a) overrides
)

File diff suppressed because it is too large Load diff

View file

@ -1,45 +0,0 @@
{ stdenv, config, fetchurl, callPackage }:
let
inherit (stdenv.lib) fold optional;
gemsMergeableFun = { generatedFuns ? [], patchFuns ? [], overrideFuns ? [] }:
let
generatedAttrs = map (f: f customGems) generatedFuns;
generatedGems = map (a: a.gems) generatedAttrs;
gem = callPackage ./gem.nix {
patches = map (f: callPackage f { inherit gems; }) patchFuns;
overrides = map (f: callPackage f { }) overrideFuns;
};
customGems = stdenv.lib.mapAttrs gem (fold (x: y: x // y) { } generatedGems);
gems = fold (x: y: x // y) customGems (map (a: a.aliases) generatedAttrs);
in
gems // {
merge = { generated ? null, patches ? null, overrides ? null }:
gemsMergeableFun {
generatedFuns = generatedFuns ++ optional (generated != null) generated;
patchFuns = patchFuns ++ optional (patches != null) patches;
overrideFuns = overrideFuns ++ optional (overrides != null) overrides;
};
};
in
((gemsMergeableFun { }).merge {
generated = import ./generated.nix;
patches = import ./patches.nix;
overrides = import ./overrides.nix;
}).merge (
let
localGemDir = (builtins.getEnv "HOME") + "/.nixpkgs/gems/";
getLocalGemFun = name:
let
file = localGemDir + name + ".nix";
fallback =
if builtins.pathExists file then import (builtins.toPath file)
else null;
in
stdenv.lib.attrByPath [ "gems" name ] fallback config;
in
{
generated = getLocalGemFun "generated";
patches = getLocalGemFun "patches";
overrides = getLocalGemFun "overrides";
})

View file

@ -0,0 +1,69 @@
{ ruby, lib, callPackage, gemFixes, fetchurl, fetchgit, buildRubyGem }@defs:
# This function builds a set of gems. You first convert your Gemfile to an attrset
# called a "gemset", and then use this function to build the gemset.
#
# A gemset looks like the following:
#
# {
# libv8 = {
# version = "3.16.14.7";
# src = {
# type = "gem";
# sha256 = "...";
# };
# };
# therubyracer = {
# version = "0.12.1";
# dependencies = [ "libv8" ];
# src = {
# type = "gem";
# sha256 = "...";
# };
# };
# }
#
# If you use these gems as build inputs, the GEM_PATH will be updated
# appropriately, and command like `bundle exec` should work out of the box.
{ gemset, ruby ? defs.ruby, fixes ? gemFixes }@args:
let
const = x: y: x;
fetchers.path = attrs: attrs.src.path;
fetchers.gem = attrs: fetchurl {
url = "${attrs.src.source or "https://rubygems.org"}/downloads/${attrs.name}-${attrs.version}.gem";
inherit (attrs.src) sha256;
};
fetchers.git = attrs: fetchgit {
inherit (attrs.src) url rev sha256 fetchSubmodules;
leaveDotGit = true;
};
instantiate = (attrs:
let
defaultAttrs = {
name = "${attrs.name}-${attrs.version}";
inherit ruby gemPath;
};
gemPath = map (name: gemset''."${name}") (attrs.dependencies or []);
fixedAttrs = attrs // (fixes."${attrs.name}" or (const {})) attrs;
withSource = fixedAttrs //
(if (lib.isDerivation fixedAttrs.src || builtins.isString fixedAttrs.src)
then {}
else { src = (fetchers."${fixedAttrs.src.type}" fixedAttrs); });
in
buildRubyGem (withSource // defaultAttrs)
);
gemset' = if builtins.isAttrs gemset then gemset else import gemset;
gemset'' = lib.flip lib.mapAttrs gemset' (name: attrs:
if (lib.isDerivation attrs)
then attrs
else instantiate (attrs // { inherit name; })
);
in gemset''

View file

@ -1,5 +0,0 @@
{ xapianBindings }:
{
xapian_full = xapianBindings.merge { cfg = { rubySupport = true; }; };
}

View file

@ -88,7 +88,8 @@ stdenv.mkDerivation rec {
minorVersion = "8";
teenyVersion = "7";
patchLevel = "374";
libPath = "lib/ruby/${majorVersion}.${minorVersion}";
gemPath = "lib/ruby/gems/${majorVersion}.${minorVersion}";
rubyEngine = "ruby";
libPath = "lib/${rubyEngine}/${majorVersion}.${minorVersion}.${teenyVersion}";
gemPath = "lib/${rubyEngine}/gems/${majorVersion}.${minorVersion}.${teenyVersion}";
};
}

View file

@ -108,7 +108,8 @@ stdenv.mkDerivation rec {
minorVersion = "9";
teenyVersion = "3";
patchLevel = "547";
libPath = "lib/ruby/${majorVersion}.${minorVersion}";
gemPath = "lib/ruby/gems/${majorVersion}.${minorVersion}";
rubyEngine = "ruby";
libPath = "lib/${rubyEngine}/${majorVersion}.${minorVersion}.${teenyVersion}";
gemPath = "lib/${rubyEngine}/gems/${majorVersion}.${minorVersion}.${teenyVersion}";
};
}

View file

@ -91,7 +91,8 @@ stdenv.mkDerivation rec {
minorVersion = "0";
teenyVersion = "0";
patchLevel = "481";
libPath = "lib/ruby/${majorVersion}.${minorVersion}";
gemPath = "lib/ruby/gems/${majorVersion}.${minorVersion}";
rubyEngine = "ruby";
libPath = "lib/${rubyEngine}/${majorVersion}.${minorVersion}.${teenyVersion}";
gemPath = "lib/${rubyEngine}/gems/${majorVersion}.${minorVersion}.${teenyVersion}";
};
}

View file

@ -106,7 +106,8 @@ stdenv.mkDerivation rec {
minorVersion = "1";
teenyVersion = "0";
patchLevel = "0";
libPath = "lib/ruby/${majorVersion}.${minorVersion}";
gemPath = "lib/ruby/gems/${majorVersion}.${minorVersion}";
rubyEngine = "ruby";
libPath = "lib/${rubyEngine}/${majorVersion}.${minorVersion}.${teenyVersion}";
gemPath = "lib/${rubyEngine}/gems/${majorVersion}.${minorVersion}.${teenyVersion}";
};
}

View file

@ -105,7 +105,8 @@ stdenv.mkDerivation rec {
minorVersion = "1";
teenyVersion = "1";
patchLevel = "0";
libPath = "lib/ruby/${majorVersion}.${minorVersion}";
gemPath = "lib/ruby/gems/${majorVersion}.${minorVersion}";
rubyEngine = "ruby";
libPath = "lib/${rubyEngine}/${majorVersion}.${minorVersion}.${teenyVersion}";
gemPath = "lib/${rubyEngine}/gems/${majorVersion}.${minorVersion}.${teenyVersion}";
};
}

View file

@ -104,7 +104,8 @@ stdenv.mkDerivation rec {
minorVersion = "1";
teenyVersion = "2";
patchLevel = "353";
libPath = "lib/ruby/${majorVersion}.${minorVersion}";
gemPath = "lib/ruby/gems/${majorVersion}.${minorVersion}";
rubyEngine = "ruby";
libPath = "lib/${rubyEngine}/${majorVersion}.${minorVersion}.${teenyVersion}";
gemPath = "lib/${rubyEngine}/gems/${majorVersion}.${minorVersion}.${teenyVersion}";
};
}

View file

@ -108,7 +108,8 @@ stdenv.mkDerivation rec {
minorVersion = "1";
teenyVersion = "3";
patchLevel = "0";
libPath = "lib/ruby/${majorVersion}.${minorVersion}";
gemPath = "lib/ruby/gems/${majorVersion}.${minorVersion}";
rubyEngine = "ruby";
libPath = "lib/${rubyEngine}/${majorVersion}.${minorVersion}.${teenyVersion}";
gemPath = "lib/${rubyEngine}/gems/${majorVersion}.${minorVersion}.${teenyVersion}";
};
}

View file

@ -1,10 +1,11 @@
args : with args;
rec {
version = "1.8.25";
rec {
name = "rubygems-" + version;
version = "2.4.1";
src = fetchurl {
url = "http://production.cf.rubygems.org/rubygems/${name}.tgz";
sha256 = "1j0wiy829nsfrpdzr9xzs39jf1lga3f5b7773vxqfs3lz3fli4v4";
sha256 = "0cpr6cx3h74ykpb0cp4p4xg7a8j0bhz3sk271jq69l4mm4zy4h4f";
};
buildInputs = [ruby makeWrapper];
@ -23,7 +24,6 @@ rec {
/* doConfigure should be specified separately */
phaseNames = ["doPatch" "doInstall"];
name = "rubygems-" + version;
meta = {
description = "Ruby gems package collection";
longDescription = ''

View file

@ -0,0 +1,70 @@
{ stdenv, lib, fetchurl, gyp, readline, python, which, icu, utillinux}:
assert readline != null;
let
arch = if stdenv.is64bit then "x64" else "ia32";
in
stdenv.mkDerivation rec {
name = "v8-${version}";
version = "3.16.14";
src = fetchurl {
url = "https://commondatastorage.googleapis.com/chromium-browser-official/"
+ "${name}.tar.bz2";
sha256 = "073f33zcb7205jp9g5ha5d7j2hfa98zs0jql572nb552z0xw3rkz";
};
configurePhase = stdenv.lib.optionalString stdenv.isDarwin ''
ln -s /usr/bin/xcodebuild $TMPDIR
export PATH=$TMPDIR:$PATH
'' + ''
PYTHONPATH="tools/generate_shim_headers:$PYTHONPATH" \
${gyp}/bin/gyp \
-f make \
--generator-output="out" \
-Dflock_index=0 \
-Dv8_enable_i18n_support=1 \
-Duse_system_icu=1 \
-Dconsole=readline \
-Dcomponent=shared_library \
-Dv8_target_arch=${arch} \
--depth=. -Ibuild/standalone.gypi \
build/all.gyp
'';
nativeBuildInputs = [ which ];
buildInputs = [ readline python icu ] ++ lib.optional stdenv.isLinux utillinux;
NIX_CFLAGS_COMPILE = "-Wno-error";
buildFlags = [
"-C out"
"builddir=$(CURDIR)/Release"
"BUILDTYPE=Release"
];
enableParallelBuilding = true;
installPhase = ''
install -vD out/Release/d8 "$out/bin/d8"
${if stdenv.system == "x86_64-darwin" then ''
install -vD out/Release/lib.target/libv8.dylib "$out/lib/libv8.dylib"
'' else ''
install -vD out/Release/lib.target/libv8.so "$out/lib/libv8.so"
''}
cp -vr include "$out/"
'';
postFixup = if stdenv.isDarwin then ''
install_name_tool -change /usr/local/lib/libv8.dylib $out/lib/libv8.dylib $out/bin/d8
install_name_tool -id $out/lib/libv8.dylib $out/lib/libv8.dylib
'' else null;
meta = with stdenv.lib; {
description = "V8 is Google's open source JavaScript engine";
platforms = platforms.linux ++ platforms.darwin;
license = licenses.bsd3;
};
}

View file

@ -42,7 +42,6 @@ composableDerivation.composableDerivation {} rec {
name = "ruby";
enable = {
buildInputs = [ ruby ];
# export same env vars as in rubyLibs
preConfigure = ''
export RUBY_LIB=$out/${ruby.libPath}
export RUBY_LIB_ARCH=$RUBY_LIB

View file

@ -42,7 +42,6 @@ composableDerivation.composableDerivation {} rec {
name = "ruby";
enable = {
buildInputs = [ ruby ];
# export same env vars as in rubyLibs
preConfigure = ''
export RUBY_LIB=$out/${ruby.libPath}
export RUBY_LIB_ARCH=$RUBY_LIB

View file

@ -1,11 +1,11 @@
{ stdenv, fetchurl, libuuid, zlib }:
stdenv.mkDerivation {
name = "xapian-1.2.8";
name = "xapian-1.2.19";
src = fetchurl {
url = http://oligarchy.co.uk/xapian/1.2.8/xapian-core-1.2.8.tar.gz;
sha256 = "00411ebac66a5592b87fc57ccfeb234c84b929ed23c185befb5df9929df3d4f9";
url = http://oligarchy.co.uk/xapian/1.2.19/xapian-core-1.2.19.tar.xz;
sha256 = "11a7lm3w3pchk4rx144nc2p31994spyqmldm18ph86zzi01jcy2a";
};
buildInputs = [ libuuid zlib ];

View file

@ -1,9 +1,16 @@
{ stdenv, fetchurl, dpkg, curl, libarchive, openssl, ruby, rubyLibs, libiconvOrLibc
{ stdenv, fetchurl, dpkg, curl, libarchive, openssl, ruby, buildRubyGem, libiconvOrLibc
, libxml2, libxslt }:
assert stdenv.system == "x86_64-linux" || stdenv.system == "i686-linux";
let version = "1.6.5";
let
version = "1.6.5";
rake = buildRubyGem {
inherit ruby;
name = "rake-10.3.2";
sha256 = "0nvpkjrpsk8xxnij2wd1cdn6arja9q11sxx4aq4fz18bc6fss15m";
};
in
stdenv.mkDerivation rec {
name = "vagrant-${version}";
@ -58,7 +65,7 @@ stdenv.mkDerivation rec {
ln -s ${ruby}/bin/erb opt/vagrant/embedded/bin
ln -s ${ruby}/bin/gem opt/vagrant/embedded/bin
ln -s ${ruby}/bin/irb opt/vagrant/embedded/bin
ln -s ${rubyLibs.rake}/bin/rake opt/vagrant/embedded/bin
ln -s ${rake}/bin/rake opt/vagrant/embedded/bin
ln -s ${ruby}/bin/rdoc opt/vagrant/embedded/bin
ln -s ${ruby}/bin/ri opt/vagrant/embedded/bin
ln -s ${ruby}/bin/ruby opt/vagrant/embedded/bin

View file

@ -16,7 +16,7 @@ in
packageOverrides = {
rubyCollection = collection {
name = "ruby";
list = let l = rubyLibs; in
list = let l = rubyPackages; in
[ pkgs.ruby l.chronic l.sup ];
};
}

View file

@ -0,0 +1,6 @@
# A sample Gemfile
source "https://rubygems.org"
gem "uglifier"
gem "sass"
gem "therubyracer"

View file

@ -0,0 +1,22 @@
GEM
remote: https://rubygems.org/
specs:
execjs (2.0.2)
json (1.8.1)
libv8 (3.16.14.3)
ref (1.0.5)
sass (3.3.6)
therubyracer (0.12.1)
libv8 (~> 3.16.14.0)
ref
uglifier (2.5.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
PLATFORMS
ruby
DEPENDENCIES
sass
therubyracer
uglifier

View file

@ -1,8 +1,15 @@
{ stdenv, lib, go, fetchgit, fetchhg, fetchbzr, fetchFromGitHub
, ruby, rubyLibs, nodejs }:
{ stdenv, lib, go, fetchgit, fetchhg, fetchbzr, fetchFromGitHub , ruby , nodejs
, bundlerEnv }:
let
version = "0.4.1";
# `sass` et al
gems = bundlerEnv {
name = "consul-deps";
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
gemset = ./gemset.nix;
};
in
with lib;
@ -13,13 +20,7 @@ stdenv.mkDerivation {
inherit stdenv lib fetchgit fetchhg fetchbzr fetchFromGitHub;
};
buildInputs = [ go ruby rubyLibs.sass nodejs ];
configurePhase = flip concatMapStrings
(with rubyLibs; [ execjs json minitest rake rdoc sass uglifier ])
(gem: ''
export GEM_PATH="$GEM_PATH:${gem}/${ruby.gemPath}"
'');
buildInputs = [ go ruby gems nodejs ];
buildPhase = ''
# Build consul binary

View file

@ -0,0 +1,59 @@
{
execjs = {
version = "2.0.2";
source = {
type = "gem";
sha256 = "167kbkyql7nvvwjsgdw5z8j66ngq7kc59gxfwsxhqi5fl1z0jbjs";
};
};
json = {
version = "1.8.1";
source = {
type = "gem";
sha256 = "0002bsycvizvkmk1jyv8px1hskk6wrjfk4f7x5byi8gxm6zzn6wn";
};
};
libv8 = {
version = "3.16.14.3";
source = {
type = "gem";
sha256 = "1arjjbmr9zxkyv6pdrihsz1p5cadzmx8308vgfvrhm380ccgridm";
};
};
ref = {
version = "1.0.5";
source = {
type = "gem";
sha256 = "19qgpsfszwc2sfh6wixgky5agn831qq8ap854i1jqqhy1zsci3la";
};
};
sass = {
version = "3.3.6";
source = {
type = "gem";
sha256 = "0ra0kxx52cgyrq6db7a1vysk984ilshbx40bcf527k8b3fha6k5r";
};
};
therubyracer = {
version = "0.12.1";
source = {
type = "gem";
sha256 = "106fqimqyaalh7p6czbl5m2j69z8gv7cm10mjb8bbb2p2vlmqmi6";
};
dependencies = [
"libv8"
"ref"
];
};
uglifier = {
version = "2.5.0";
source = {
type = "gem";
sha256 = "0b9kxgyg8cv3g1bp6casndfzfy71jd9xyjxwng0lj90vzqrgjp20";
};
dependencies = [
"execjs"
"json"
];
};
}

View file

@ -0,0 +1,3 @@
source 'https://rubygems.org'
gem "riemann-dash", "0.2.9"

View file

@ -0,0 +1,27 @@
GEM
remote: https://rubygems.org/
specs:
erubis (2.7.0)
multi_json (1.3.6)
rack (1.5.2)
rack-protection (1.5.3)
rack
riemann-dash (0.2.9)
erubis (>= 2.7.0)
multi_json (= 1.3.6)
sass (>= 3.1.14)
sinatra (~> 1.4.5)
webrick (~> 1.3.1)
sass (3.4.8)
sinatra (1.4.5)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
tilt (1.4.1)
webrick (1.3.1)
PLATFORMS
ruby
DEPENDENCIES
riemann-dash (= 0.2.9)

View file

@ -0,0 +1,8 @@
{ bundlerEnv }:
bundlerEnv {
name = "riemann-dash-0.2.9";
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
gemset = ./gemset.nix;
}

View file

@ -0,0 +1,80 @@
{
erubis = {
version = "2.7.0";
source = {
type = "gem";
sha256 = "1fj827xqjs91yqsydf0zmfyw9p4l2jz5yikg3mppz6d7fi8kyrb3";
};
};
multi_json = {
version = "1.3.6";
source = {
type = "gem";
sha256 = "0q2zjfvd2ibds9g9nzf2p1b47fc1wqliwfywv5pw85w15lmy91yr";
};
};
rack = {
version = "1.5.2";
source = {
type = "gem";
sha256 = "19szfw76cscrzjldvw30jp3461zl00w4xvw1x9lsmyp86h1g0jp6";
};
};
rack-protection = {
version = "1.5.3";
source = {
type = "gem";
sha256 = "0cvb21zz7p9wy23wdav63z5qzfn4nialik22yqp6gihkgfqqrh5r";
};
dependencies = [
"rack"
];
};
riemann-dash = {
version = "0.2.9";
source = {
type = "gem";
sha256 = "0ws5wmjbv8w9lcr3i2mdinj2qm91p6c85k6c067i67cf0p90jxq3";
};
dependencies = [
"erubis"
"multi_json"
"sass"
"sinatra"
"webrick"
];
};
sass = {
version = "3.4.8";
source = {
type = "gem";
sha256 = "1ianyj2figwk314h10fkzpjql2xxi5l4njv1h0w8iyzjda85rqlp";
};
};
sinatra = {
version = "1.4.5";
source = {
type = "gem";
sha256 = "0qyna3wzlnvsz69d21lxcm3ixq7db08mi08l0a88011qi4qq701s";
};
dependencies = [
"rack"
"rack-protection"
"tilt"
];
};
tilt = {
version = "1.4.1";
source = {
type = "gem";
sha256 = "00sr3yy7sbqaq7cb2d2kpycajxqf1b1wr1yy33z4bnzmqii0b0ir";
};
};
webrick = {
version = "1.3.1";
source = {
type = "gem";
sha256 = "0s42mxihcl2bx0h9q0v2syl70qndydfkl39a06h9il17p895ya8g";
};
};
}

View file

@ -0,0 +1,2 @@
source "https://rubygems.org"
gem "nokogiri"

View file

@ -0,0 +1,12 @@
GEM
remote: https://rubygems.org/
specs:
mini_portile (0.6.2)
nokogiri (1.6.5)
mini_portile (~> 0.6.0)
PLATFORMS
ruby
DEPENDENCIES
nokogiri

View file

@ -1,7 +1,14 @@
{ stdenv, fetchgit, autoconf, automake, libtool, pkgconfig, glib, libdaemon
, mpd_clientlib, curl, sqlite, ruby, rubyLibs, libnotify, pandoc }:
{ stdenv, fetchgit, autoconf, automake, libtool, pkgconfig, glib, libdaemon, buildRubyGem
, mpd_clientlib, curl, sqlite, ruby, bundlerEnv, libnotify, pandoc }:
stdenv.mkDerivation rec {
let
gemEnv = bundlerEnv {
name = "mpdcron-bundle";
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
gemset = ./gemset.nix;
};
in stdenv.mkDerivation rec {
version = "20130809";
name = "mpdcron-${version}";
@ -21,7 +28,7 @@ stdenv.mkDerivation rec {
buildInputs =
[ autoconf automake libtool pkgconfig glib libdaemon pandoc
mpd_clientlib curl sqlite ruby rubyLibs.nokogiri libnotify ];
mpd_clientlib curl sqlite ruby gemEnv libnotify ];
preConfigure = ''
./autogen.sh

View file

@ -0,0 +1,19 @@
{
"mini_portile" = {
version = "0.6.2";
source = {
type = "gem";
sha256 = "0h3xinmacscrnkczq44s6pnhrp4nqma7k056x5wv5xixvf2wsq2w";
};
};
"nokogiri" = {
version = "1.6.5";
source = {
type = "gem";
sha256 = "1xmxz6fa0m4p7c7ngpgz6gjgv65lzz63dsf0b6vh7gs2fkiw8j7l";
};
dependencies = [
"mini_portile"
];
};
}

View file

@ -1,23 +0,0 @@
{ stdenv, rubygems, rubyLibs, ruby, makeWrapper }:
stdenv.mkDerivation rec {
name = "gem-nix";
buildInputs = [ ruby rubygems rubyLibs.nix makeWrapper ];
phases = ["installPhase"];
installPhase = ''
mkdir -p $out/bin
echo 'exec ${rubygems}/bin/gem nix "$@"' >> $out/bin/gem-nix
chmod +x $out/bin/gem-nix
wrapProgram $out/bin/gem-nix \
--set GEM_PATH $GEM_PATH
'';
meta = with stdenv.lib; {
description = "gem nix command in a nice wrapper";
platforms = platforms.unix;
maintainers = [ maintainers.iElectric ];
};
}

View file

@ -680,7 +680,7 @@ let
cloud-init = callPackage ../tools/virtualization/cloud-init { };
consul = callPackage ../servers/consul {
inherit ruby rubyLibs;
# inherit ruby;
};
consul_ui = consul.ui;
@ -4306,6 +4306,18 @@ let
wrapPython = pythonPackages.wrapPython;
};
bundix = callPackage ../development/interpreters/ruby/bundix {
ruby = ruby_2_1_3;
};
bundler = callPackage ../development/interpreters/ruby/bundler.nix { };
bundler_HEAD = import ../development/interpreters/ruby/bundler-head.nix {
inherit buildRubyGem coreutils fetchgit;
};
defaultGemConfig = callPackage ../development/interpreters/ruby/bundler-env/default-gem-config.nix { };
buildRubyGem = callPackage ../development/interpreters/ruby/gem.nix { };
loadRubyEnv = callPackage ../development/interpreters/ruby/load-ruby-env.nix { };
bundlerEnv = callPackage ../development/interpreters/ruby/bundler-env { };
ruby_1_8_7 = callPackage ../development/interpreters/ruby/ruby-1.8.7.nix { };
ruby_1_9_3 = callPackage ../development/interpreters/ruby/ruby-1.9.3.nix { };
ruby_2_0_0 = lowPrio (callPackage ../development/interpreters/ruby/ruby-2.0.0.nix { });
@ -4323,12 +4335,6 @@ let
ruby_2_1 = ruby_2_1_3;
ruby_2_2 = ruby_2_2_0;
rubyLibs = recurseIntoAttrs (callPackage ../development/interpreters/ruby/libs.nix { });
rake = rubyLibs.rake;
rubySqlite3 = callPackage ../development/ruby-modules/sqlite3 { };
rubygemsFun = ruby: builderDefsPackage (import ../development/interpreters/ruby/rubygems.nix) {
inherit ruby makeWrapper;
};
@ -7219,6 +7225,10 @@ let
ucommon = callPackage ../development/libraries/ucommon { };
v8_3_16_14 = callPackage ../development/libraries/v8/3.16.14.nix {
inherit (pythonPackages) gyp;
};
v8 = callPackage ../development/libraries/v8 {
inherit (pythonPackages) gyp;
};
@ -7941,6 +7951,7 @@ let
newrelic-sysmond = callPackage ../servers/monitoring/newrelic-sysmond { };
riemann = callPackage ../servers/monitoring/riemann { };
riemann-dash = callPackage ../servers/monitoring/riemann-dash { };
oidentd = callPackage ../servers/identd/oidentd { };
@ -10621,42 +10632,14 @@ let
pcmanfm = callPackage ../applications/misc/pcmanfm { };
ruby_gpgme = callPackage ../development/libraries/ruby_gpgme {
ruby = ruby_1_9_3;
hoe = rubyLibs.hoe;
};
ruby_ncursesw_sup = callPackage ../development/libraries/ruby_ncursesw_sup { };
shotcut = callPackage ../applications/video/shotcut { mlt = mlt-qt5; };
smplayer = callPackage ../applications/video/smplayer { };
smtube = callPackage ../applications/video/smtube {};
sup = with rubyLibs; callPackage ../applications/networking/mailreaders/sup {
ruby = ruby_1_9_3.override {
cursesSupport = true;
};
inherit gettext highline iconv locale lockfile
text trollop xapian_ruby which;
rmail_sup = ""; # missing
unicode = "";
# See https://github.com/NixOS/nixpkgs/issues/1804 and
# https://github.com/NixOS/nixpkgs/issues/2146
bundler = pkgs.lib.overrideDerivation pkgs.rubyLibs.bundler (
oldAttrs: {
dontPatchShebangs = 1;
}
);
chronic = chronic;
gpgme = ruby_gpgme;
mime_types = mime_types;
ncursesw_sup = ruby_ncursesw_sup;
rake = rake;
sup = callPackage ../applications/networking/mailreaders/sup {
ruby = ruby_1_9_3.override { cursesSupport = true; };
};
synfigstudio = callPackage ../applications/graphics/synfigstudio {

View file

@ -13156,7 +13156,7 @@ let
propagatedBuildInputs = with self; [ dateutil ];
preInstall = stdenv.lib.optionalString stdenv.isDarwin ''
sed -i 's|^\([ ]*\)self.bin_path.*$|\1self.bin_path = "${pkgs.rubyLibs.terminal_notifier}/bin/terminal-notifier"|' build/lib/pync/TerminalNotifier.py
sed -i 's|^\([ ]*\)self.bin_path.*$|\1self.bin_path = "${pkgs.rubyPackages.terminal_notifier}/bin/terminal-notifier"|' build/lib/pync/TerminalNotifier.py
'';
meta = with stdenv.lib; {