From c786da0569178100d45c03bd5e09de0d4e4199ca Mon Sep 17 00:00:00 2001 From: Alexander Flatter Date: Sun, 31 Aug 2014 19:32:34 +0200 Subject: [PATCH] importGems now reads attrsets instead of derivations --- pkgs/development/interpreters/ruby/fixes.nix | 94 +++++++++ pkgs/development/interpreters/ruby/gem.nix | 18 +- pkgs/development/interpreters/ruby/gems.nix | 183 ++++-------------- .../development/interpreters/ruby/patches.nix | 79 -------- 4 files changed, 149 insertions(+), 225 deletions(-) create mode 100644 pkgs/development/interpreters/ruby/fixes.nix delete mode 100644 pkgs/development/interpreters/ruby/patches.nix diff --git a/pkgs/development/interpreters/ruby/fixes.nix b/pkgs/development/interpreters/ruby/fixes.nix new file mode 100644 index 00000000000..a8514375c74 --- /dev/null +++ b/pkgs/development/interpreters/ruby/fixes.nix @@ -0,0 +1,94 @@ +# 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, gemset, buildRubyGem, writeScript, ruby, libxml2, libxslt, python, stdenv +, which, postgresql, v8_3_16_14, clang }: + +let + v8 = v8_3_16_14; + + gems = lib.mapAttrs (name: config: + if (lib.isDerivation config) then config + else (instantiate name config) + ) gemset; + + instantiate = (name: attrs: + let + # Turn dependency strings into actual derivations. + gemPath = map (name: builtins.getAttr name gems) (attrs.dependencies or []); + fix = if (builtins.hasAttr name fixes) + then (builtins.getAttr name fixes) attrs + else {}; + in + buildRubyGem ({ + name = attrs.name; + sha256 = attrs.sha256; + inherit gemPath; + # Disable the checkPhase as there no single way to run tests for a given + # gem: https://github.com/rubygems/rubygems/issues/730 + checkPhase = ":"; + # Gems downloaded from rubygems.org don't need to be built again. + dontBuild = true; + } // fix) + ); + + fixes = { + bundler = attrs: { + dontPatchShebangs = 1; + }; + + libv8 = attrs: { + buildFlags = [ "--with-system-v8" ]; + buildInputs = [ which v8 python ]; + }; + + nokogiri = attrs: { + buildFlags = [ + "--with-xml2-dir=${libxml2}" + "--with-xml2-include=${libxml2}/include/libxml2" + "--with-xslt-dir=${libxslt}" + "--use-system-libraries" + ]; + }; + + therubyracer = attrs: { + dontBuild = false; + + preBuild = '' + addToSearchPath RUBYLIB "${gems.libv8}/${ruby.gemPath}/gems/libv8-3.16.14.3/lib" + addToSearchPath RUBYLIB "${gems.libv8}/${ruby.gemPath}/gems/libv8-3.16.14.3/ext" + ln -s ${clang}/bin/clang $TMPDIR/gcc + ln -s ${clang}/bin/clang++ $TMPDIR/g++ + export PATH=$TMPDIR:$PATH + ''; + + postInstall = stdenv.lib.optionalString stdenv.isDarwin '' + cat >> $out/nix-support/setup-hook <> $out/nix-support/setup-hook <