JRuby withPackages support

Is there any limitation I should know about whether JRuby could / should support withPackages ?

According to nixpkgs/ruby.section.md at cf2314ff9a73bfa5c4df814418185ee7fb274067 · NixOS/nixpkgs · GitHub you can write similar nix expressions for CRuby

with import <nixpkgs> {};
ruby.withPackages (ps: with ps; [ nokogiri pry ])

Looking at the source it seems to be minimally based around buildEnv

(Relevant snippet)

  withPackages = selector:
      selected = selector gems;

      gemEnv = buildEnv {
        name = "ruby-gems";
        paths = selected;
        pathsToLink = [ "/lib" "/bin" "/nix-support" ];

      wrappedRuby = stdenv.mkDerivation {
        name = "wrapped-${ruby.name}";
        nativeBuildInputs = [ makeWrapper ];
        buildCommand = ''
          mkdir -p $out/bin
          for i in ${ruby}/bin/*; do
            makeWrapper "$i" $out/bin/$(basename "$i") --set GEM_PATH ${gemEnv}/${ruby.gemPath}

I’m trying to grok through the source to understand how I can make the contribution; but I don’t really understand the passthru attrset.

Another interesting problem; is that the top-level Ruby packages (that contains all the gems); don’t contain any platform information to restrict whether they include C-extensions or Java.

Appreciate any feedback here.

CC @manveru

1 Like

Quick follow-up why I’m interested in this; although I’m not using bundix; I’d like to hydrate my development environment (nix-shell) with Bundler & Rake at the very least.