How do I override the stdenv that maven.buildMavenPackage uses?

I have a Java tool that I build with maven.buildMavenPackage. I think that ultimately resolves to a stdenv.mkDerivation call. When I build the tool at the terminal with nix build, I see that it pulls in gcc. I understand that stdenv comes with gcc. And I’m sure my Java compilation doesn’t need a C compiler. What’s the nixiest way of excluding gcc?

I’ve been trying my darndest to inject a stdenv = stdenvNoCC; at maven/package.nix:57 with no success. The only thing I’ve been able to get to work is calling callPackage myself with the path to build-maven-package.nix on my system and injecting stdenvNoCC at that point. But my gut has been screaming at me that there’s gotta be an easier, nixier way.

Thank you

I don’t think you can override stdenv via the buildMavenPackage passthru. The code exposes an overrideMavenAttrs and that only touches the args of buildMavenPackage.

Maybe you can use the buildMaven passthru instead? this one allows an override of the stdenv but I think it’s a bit more cumbersome to use than buildMavenPackage.

I’m no expert but your solution with callPackage sounds good.