mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-20 20:03:24 +00:00
loadRubyEnv instantiates sources
This commit is contained in:
parent
2cb31d576a
commit
4d3932a29e
@ -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:
|
loadRubyEnv = path: config:
|
||||||
let
|
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;
|
ruby = config.ruby;
|
||||||
rubyLibs = rubyLibsWith ruby;
|
rubyLibs = rubyLibsWith ruby;
|
||||||
gems = rubyLibs.importGems gemset (config.gemOverrides or (gemset: {}));
|
gems = rubyLibs.importGems gemset (config.gemOverrides or (gemset: {}));
|
||||||
|
Loading…
Reference in New Issue
Block a user