summary refs log tree commit diff
path: root/pkgs/development/interpreters
diff options
context:
space:
mode:
authorAlexander Flatter <flatter@fastmail.fm>2014-09-17 15:11:24 +0200
committerCharles Strahan <charles.c.strahan@gmail.com>2014-10-27 21:55:12 +0000
commit4d3932a29e614419edf0972f0892e6e9b0dbfab7 (patch)
tree9fba228397aa7e7dfba7d29b1ccddde09c3d7fbd /pkgs/development/interpreters
parent2cb31d576a83861a05f2596d5a5e8d1dee661de6 (diff)
downloadnixpkgs-4d3932a29e614419edf0972f0892e6e9b0dbfab7.tar
nixpkgs-4d3932a29e614419edf0972f0892e6e9b0dbfab7.tar.gz
nixpkgs-4d3932a29e614419edf0972f0892e6e9b0dbfab7.tar.bz2
nixpkgs-4d3932a29e614419edf0972f0892e6e9b0dbfab7.tar.lz
nixpkgs-4d3932a29e614419edf0972f0892e6e9b0dbfab7.tar.xz
nixpkgs-4d3932a29e614419edf0972f0892e6e9b0dbfab7.tar.zst
nixpkgs-4d3932a29e614419edf0972f0892e6e9b0dbfab7.zip
loadRubyEnv instantiates sources
Diffstat (limited to 'pkgs/development/interpreters')
-rw-r--r--pkgs/development/interpreters/ruby/bundix.nix33
1 files changed, 31 insertions, 2 deletions
diff --git a/pkgs/development/interpreters/ruby/bundix.nix b/pkgs/development/interpreters/ruby/bundix.nix
index 4f745cfd62a..f662517b2de 100644
--- a/pkgs/development/interpreters/ruby/bundix.nix
+++ b/pkgs/development/interpreters/ruby/bundix.nix
@@ -1,9 +1,38 @@
-{rubyLibsWith, callPackage, lib}:
+{rubyLibsWith, callPackage, lib, fetchurl, fetchgit}:
+
+let
+
+  sourceInstantiators = {
+    # Many ruby people use `git ls-files` to compose their gemspecs.
+    git = (attrs: fetchgit { inherit (attrs) url rev sha256 leaveDotGit; });
+    url = (attrs: fetchurl { inherit (attrs) url sha256; });
+  };
+
+in
 
 {
+  # Loads a set containing a ruby environment definition. The set's `gemset`
+  # key is expected to contain a set of gems. Optionally, the `ruby_version`
+  # key can be set to a string. A gem definition looks like this:
+  #
+  #  rack-test = {
+  #    name = "rack-test-0.6.2";
+  #    src = {
+  #      type = "url";
+  #      url = "https://rubygems.org/downloads/rack-test-0.6.2.gem";
+  #      sha256 = "01mk715ab5qnqf6va8k3hjsvsmplrfqpz6g58qw4m3l8mim0p4ky";
+  #    };
+  #    dependencies = [ "rack" ];
+  #  };
   loadRubyEnv = path: config:
     let
-      expr = callPackage path {};
+      expr = import path;
+      gemset = lib.mapAttrs (name: attrs:
+        attrs // {
+          src = (builtins.getAttr attrs.src.type sourceInstantiators) attrs.src;
+          dontBuild = !(attrs.src.type == "git");
+        }
+      ) expr.gemset;
       ruby = config.ruby;
       rubyLibs = rubyLibsWith ruby;
       gems = rubyLibs.importGems gemset (config.gemOverrides or (gemset: {}));