Gradle6 Installation is failing in linux

I am trying to install gradle in WSL2. It’s failing because of following issue but same code is working in MAC:

post-installation fixup
/build/gradle-6.8.3/patching /build/gradle-6.8.3
/nix/store/sx5hrbrr1g47klxk7x429qd1xwhq9dqq-stdenv-linux/setup: line 1310: /nix/store/64l9jdy0xmr13qqiq2xlimfx767pr2g2-gstemp-adoptopenjdk-hotspot-bin-11.0.9/bin/jar: No such file or directory
builder for ‘/nix/store/njkcwdl8msw713mpf82xn6mms0h8l2yk-gradle-6.8.3.drv’ failed with exit code 127
error: build of ‘/nix/store/njkcwdl8msw713mpf82xn6mms0h8l2yk-gradle-6.8.3.drv’ failed

Following is my overlay script:

self: super:
with super.lib.attrsets;
with super.lib.lists;
with super.lib;

gradlePName = "gradle";

/** Apply overlay and create version maps from overlay.
** Due to many:one mappings, some versions get overwritten when a set is inverted,
** however they play out fine since they internally resolve to the same version.
generator = self.gradleGen;
pkgAttrsToVers = filterAttrs (x: y: (y != "")) (
mapAttrs (n : v : if ( isDerivation v ) then else "") generator

versToPkgAttrs = listToAttrs (
mapAttrsToList (k: v: nameValuePair v k) pkgAttrsToVers

gradleAttrsTopLvl = filter (a: (strings.hasPrefix gradlePName a)) (attrNames super);
attrs2VersTopLvl = forEach gradleAttrsTopLvl (
drv = getAttr n self;
v = if (isDerivation drv) && ((strings.getName == gradlePName) then else "";
nameValuePair n v

topLvlAttrsToVers = listToAttrs (filter (a: (a.value != "")) attrs2VersTopLvl);

topLvl2PkgAttrs = mapAttrs (n: v: versToPkgAttrs.${v} or "") topLvlAttrsToVers;

gradleGen = super.gradleGen.override { java = self.myorg.myorg-adoptopen-jdk11-latest; };
gradleOverlay = mapAttrs (n: v: gradleGen.${v} ) topLvl2PkgAttrs;

Same script is working for MAC. As per github script, I can see for linux they are handling it differently but still I don’t know why it’s failing even if **/bin/jar file is present at given location

I am getting this issue for all the versions of jdk (oracle -8 and 11, adoptopen 8 and 11 etc).
Am I missing something or it’s known bug for linux?