3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/interpreters/ruby/load-ruby-env.nix

38 lines
1,006 B
Nix
Raw Normal View History

2014-10-29 23:14:19 +00:00
{ pkgs, lib, callPackage, gemFixes, fetchurl }:
2014-10-28 01:22:17 +00:00
2014-10-28 04:16:14 +00:00
{ gemset, ruby ? pkgs.ruby, fixes ? gemFixes }@args:
2014-10-28 01:22:17 +00:00
2014-10-28 04:16:14 +00:00
let
const = x: y: x;
2014-10-28 01:22:17 +00:00
2014-10-28 04:16:14 +00:00
buildRubyGem = callPackage ./gem.nix { inherit ruby; };
2014-10-28 01:22:17 +00:00
2014-10-29 23:14:19 +00:00
fetchers.gem = attrs: fetchurl {
url = "${attrs.src.source or "https://rubygems.org"}/downloads/${attrs.name}-${attrs.version}.gem";
inherit (attrs.src) sha256;
};
instantiate = (attrs:
2014-10-28 01:22:17 +00:00
let
2014-10-28 04:16:14 +00:00
gemPath = map (name: gemset''."${name}") (attrs.dependencies or []);
2014-10-29 23:14:19 +00:00
fixedAttrs = attrs // (fixes."${attrs.name}" or (const {})) attrs;
2014-10-28 04:16:14 +00:00
in
2014-10-29 23:14:19 +00:00
buildRubyGem (
fixedAttrs // {
name = "${attrs.name}-${attrs.version}";
src = fetchers."${attrs.src.type}" attrs;
inherit gemPath;
}
)
2014-10-28 04:16:14 +00:00
);
gemset' = if builtins.isAttrs gemset then gemset else callPackage gemset { };
gemset'' = lib.flip lib.mapAttrs gemset' (name: attrs:
2014-10-29 23:14:19 +00:00
if (lib.isDerivation attrs)
then attrs
else instantiate (attrs // { inherit name; })
2014-10-28 04:16:14 +00:00
);
in gemset''