nix: use symlinks for maven dependencies derivation

This should reduce the size of the derivation by >50%.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
2020-05-05 20:00:40 +02:00
parent 3ae5f87be3
commit 954e677f0c
2 changed files with 6 additions and 4 deletions
@@ -9,10 +9,9 @@ let
mavenSourceFiles =
let
srcs = import ./maven-sources.nix { };
system = if stdenv.isDarwin then "osx" else "linux";
# Warning: This must be the same as gradlePluginVersion android/gradle.properties
version = "3.5.3-5435860";
aapt2NativePkg = "https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/${version}/aapt2-${version}-${system}";
aapt2NativePkg = "https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/${version}/aapt2-${version}-linux";
in srcs // (if !stdenv.isLinux then { } else {
# On Linux, we need to patch the interpreter in Java packages that contain native executables to use Nix's interpreter instead
"${aapt2NativePkg}" = srcs."${aapt2NativePkg}" // {
+5 -2
View File
@@ -40,13 +40,13 @@ let
mkdir -p ${directory}
${optionalString (pom-download != "") ''
cp -f "${pom-download}" "${getPOM dep.path}"
ln -s "${pom-download}" "${getPOM dep.path}"
''}
${optionalString (pom.sha1 != "") ''
echo "${pom.sha1}" > "${getPOM dep.path}.sha1"
''}
${optionalString (jar-download != "") ''
cp -f "${jar-download}" "${dep.path}.${dep.type}"
ln -s "${jar-download}" "${dep.path}.${dep.type}"
''}
${optionalString (jar.sha1 != "") ''
echo "${jar.sha1}" > "${dep.path}.${dep.type}.sha1"
@@ -54,6 +54,9 @@ let
${if dep.postCopy != "" then ''
depPath="$PWD/${dep.path}"
# postCopy can't modify the jar if it's a symlink
rm "${dep.path}.${dep.type}"
cp "${jar-download}" "${dep.path}.${dep.type}"
${dep.postCopy}
unset depPath
'' else ""