Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jemallocSupport with gems #114

Open
emptyflask opened this issue Apr 9, 2024 · 0 comments
Open

jemallocSupport with gems #114

emptyflask opened this issue Apr 9, 2024 · 0 comments

Comments

@emptyflask
Copy link

I opened an issue at bobvanderlinden/nixpkgs-ruby#118 for this as well, but wasn't sure if the bundix repo was a better place to ask.


I'm attempting to enable jemalloc with ruby, which appears to work fine, but it isn't available to gems. I thought that maybe since it was in ruby's propagatedBuildInputs, the gems would have it, but no.

        pkgs = import nixpkgs {
          inherit system;
          overlays = [ bob-ruby.overlays.default ];
        };
        rubyNix = ruby-nix.lib pkgs;
        gemset = if builtins.pathExists ./gemset.nix then import ./gemset.nix else { };
        rubyVersion = nixpkgs.lib.fileContents ./.ruby-version;

        ruby = pkgs."${rubyVersion}".override {
          jemallocSupport = true;
          yjitSupport = true;
        };

I wrote a function to add it to each gem's buildInputs, but merging that with defaultGemConfig replaces the existing builtInputs, so perhaps a "deep merge" is needed instead:

        jemallocGemConfig = builtins.listToAttrs (map (name: {
          inherit name;
          value = attrs: attrs // { buildInputs = (attrs.buildInputs or []) ++ [ pkgs.jemalloc ]; };
        }) (builtins.attrNames gemset));
      in rec {
        inherit (rubyNix {
          inherit gemset ruby;
          name = "chronos";
          gemConfig = pkgs.defaultGemConfig // jemallocGemConfig;
        }) env;
        devShells = rec {
          dev = pkgs.mkShell { buildInputs = [ env ] };
          default = dev;
        };
      };

But I'm probably thinking about this the wrong way. Surely there's some better/simpler way to use jemalloc with gems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant