From 954e677f0cd8ecd5cacced15bb045d60c856e4b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Mon, 4 May 2020 21:20:53 +0200 Subject: [PATCH] nix: use symlinks for maven dependencies derivation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should reduce the size of the derivation by >50%. Signed-off-by: Jakub SokoĊ‚owski --- nix/mobile/android/maven-and-npm-deps/maven/default.nix | 3 +-- nix/tools/maven/maven-repo-builder.nix | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/nix/mobile/android/maven-and-npm-deps/maven/default.nix b/nix/mobile/android/maven-and-npm-deps/maven/default.nix index 34a41b3a3d..078c312829 100644 --- a/nix/mobile/android/maven-and-npm-deps/maven/default.nix +++ b/nix/mobile/android/maven-and-npm-deps/maven/default.nix @@ -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}" // { diff --git a/nix/tools/maven/maven-repo-builder.nix b/nix/tools/maven/maven-repo-builder.nix index a151e90517..97a72bf248 100644 --- a/nix/tools/maven/maven-repo-builder.nix +++ b/nix/tools/maven/maven-repo-builder.nix @@ -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 ""