Jakub Sokołowski 80a75c5232
nix: patch all Gradle configs of nodejs deps
Before we were patching only `build.gradle`, which is not the only type
of Gradle config file. If we do not cover them all we can encounter
errors about missing package because they will continue using remote
repositories instead of `mavenLocal()`, to which pass Nix store path.

We also need to cover `gradlePluginPortal()` to provide plugins.

This is also necessary for the React Native upgrade:
https://github.com/status-im/status-mobile/pull/15203

Signed-off-by: Jakub Sokołowski <jakub@status.im>
2023-03-04 13:01:26 +01:00

24 lines
797 B
Nix

# This script patches build.gradle files in node_modules to use
# our local version of Maven dependencies instead of fetching them.
{ stdenv, writeScript, runtimeShell }:
writeScript "patch-maven-srcs" (''
#!${runtimeShell}
# Source setup.sh for substituteInPlace
source ${stdenv}/setup
function patchMavenSource() {
grep "$source" $1 > /dev/null && \
substituteInPlace $1 --replace "$2" "$3" 2>/dev/null
}
gradleFile="$1"
# Some of those find something, some don't, that's fine.
patchMavenSource "$gradleFile" 'mavenCentral()' 'mavenLocal()'
patchMavenSource "$gradleFile" 'google()' 'mavenLocal()'
patchMavenSource "$gradleFile" 'jcenter()' 'mavenLocal()'
patchMavenSource "$gradleFile" 'gradlePluginPortal()' 'mavenLocal()'
'')