nixpkgs/pkgs/development/interpreters/ruby/load-ruby-env.nix

26 lines
693 B
Nix
Raw Normal View History

2014-10-28 05:16:14 +01:00
{ pkgs, lib, callPackage, gemFixes }:
2014-10-28 02:22:17 +01:00
2014-10-28 05:16:14 +01:00
{ gemset, ruby ? pkgs.ruby, fixes ? gemFixes }@args:
2014-10-28 02:22:17 +01:00
2014-10-28 05:16:14 +01:00
let
const = x: y: x;
2014-10-28 02:22:17 +01:00
2014-10-28 05:16:14 +01:00
buildRubyGem = callPackage ./gem.nix { inherit ruby; };
2014-10-28 02:22:17 +01:00
2014-10-28 05:16:14 +01:00
instantiate = (name: attrs:
2014-10-28 02:22:17 +01:00
let
2014-10-28 05:16:14 +01:00
gemPath = map (name: gemset''."${name}") (attrs.dependencies or []);
fixedAttrs = attrs // (fixes."${name}" or (const {})) attrs;
in
buildRubyGem (fixedAttrs // { name = "${name}-${attrs.version}"; inherit gemPath; })
);
gemset' = if builtins.isAttrs gemset then gemset else callPackage gemset { };
gemset'' = lib.flip lib.mapAttrs gemset' (name: attrs:
if (lib.isDerivation attrs) then attrs
else (instantiate name attrs)
);
in gemset''