From 1c21e5f0a4ae7bfc430ad58fe32070316d436492 Mon Sep 17 00:00:00 2001 From: Avimitin Date: Thu, 10 Oct 2024 18:39:38 +0800 Subject: [PATCH] [nix] add conversion from https_proxy to JAVA_OPTS This could help user get rid of JAVA shit. Signed-off-by: Avimitin --- nix/pkgs/mill-builder.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nix/pkgs/mill-builder.nix b/nix/pkgs/mill-builder.nix index 2b5227c6c..fbab7ebe1 100644 --- a/nix/pkgs/mill-builder.nix +++ b/nix/pkgs/mill-builder.nix @@ -12,12 +12,22 @@ let mill ] ++ (args.nativeBuildInputs or [ ]); - impureEnvVars = [ "JAVA_OPTS" ]; + impureEnvVars = [ "https_proxy" "JAVA_OPTS" ]; buildPhase = '' runHook preBuild + export JAVA_OPTS="-Duser.home=$TMPDIR $JAVA_OPTS" + if [[ -z "$https_proxy" && ! "proxyHost" =~ "$JAVA_OPTS" ]]; then + _https_proxy="''${https_proxy#http://}" + _https_proxy="''${_https_proxy#https://}" + _https_proxy_parts=(''${_https_proxy//:/ }) + _host=''${_https_proxy_parts[0]} + _port=''${_https_proxy_parts[1]} + export JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=$_host -Dhttp.proxyPort=$_port -Dhttps.proxyHost=$_host -Dhttps.proxyPort=$_port" + fi + # Use "https://repo1.maven.org/maven2/" only to keep dependencies integrity export COURSIER_REPOSITORIES="central"