nix-community / bundix

Generates a Nix expression for your Bundler-managed application. [maintainer=@manveru]
160 stars 54 forks source link

Inject system dependency while still using common overrrides #87

Closed lokegustafsson closed 2 years ago

lokegustafsson commented 2 years ago

I have a flake.nix along the lines of

{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  inputs.flake-utils.url = "github:numtide/flake-utils";

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
        myGems = pkgs.bundlerEnv {
          name = "somegems";
          ruby = pkgs.ruby;
          gemdir = ./.;
          # Uncommenting this breaks things by removing all default overrides. How can I avoid that?
          /*
          gemConfig.some-gem-without-default-override = attrs: {
            buildInputs = with pkgs; [ ... ]
          }
          */
        };
      in {
        devShell = pkgs.mkShell {
          nativeBuildInputs = [ pkgs.myGems ];
        };
      });
}

Where gemset.nix contains gems that require injecting native dependencies. Some of these have defined overrides in https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/ruby-modules/gem-config/default.nix, some do not. I want to define some overrides for packages that do not. My problem is that doing so disables all the universal overrides, and I have no interest in duplicating the entirety of that file in mine.

lokegustafsson commented 2 years ago

I found a way:

gemConfig = pkgs.defaultGemConfig // {
  some-gem-without-default-override = attrs: { buildInputs = with pkgs; [ ... ]; };
};

This was not at all discoverable though. I found it by searching for gemConfig and finding #68