Skip to content

Commit

Permalink
[nix] add conversion from https_proxy to JAVA_OPTS
Browse files Browse the repository at this point in the history
This could help user get rid of JAVA shit.

Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin committed Oct 10, 2024
1 parent 12131dd commit 1c21e5f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion nix/pkgs/mill-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1c21e5f

Please sign in to comment.