From e69d148812feb8ea6188d84d343ac02bdabb0424 Mon Sep 17 00:00:00 2001 From: Geoff Reedy Date: Thu, 20 Oct 2022 07:58:00 -0600 Subject: [PATCH] ghidra: add support for aarch64-darwin This also changes the method used to change Java's notion of the user home directory. Instead of redirecting /etc/passwd to a generated file, the JAVA_TOOL_OPTIONS environment variable is used to provide a value for the user.home system property. The redirect method did not seem to be effective on my Monterey (12.6) system and the new approach is IMO simpler anyway. --- pkgs/tools/security/ghidra/build.nix | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/pkgs/tools/security/ghidra/build.nix b/pkgs/tools/security/ghidra/build.nix index 3e7197f543d2..23bc1d216f35 100644 --- a/pkgs/tools/security/ghidra/build.nix +++ b/pkgs/tools/security/ghidra/build.nix @@ -84,7 +84,10 @@ HERE nativeBuildInputs = [ gradle perl ] ++ lib.optional stdenv.isDarwin xcbuild; buildPhase = '' - export GRADLE_USER_HOME=$(mktemp -d) + export HOME="$NIX_BUILD_TOP/home" + mkdir -p "$HOME" + export JAVA_TOOL_OPTIONS="-Duser.home='$HOME'" + export GRADLE_USER_HOME="$HOME/.gradle" # First, fetch the static dependencies. gradle --no-daemon --info -Dorg.gradle.java.home=${openjdk11} -I gradle/support/fetchDependencies.gradle init @@ -116,21 +119,10 @@ in stdenv.mkDerivation rec { patches = [ ./0001-Use-protobuf-gradle-plugin.patch ]; postPatch = fixProtoc; - buildPhase = (lib.optionalString stdenv.isDarwin '' - export HOME=$(mktemp -d) - - # construct a dummy /etc/passwd file - something attempts to determine - # the user's "real" home using this - DUMMY_PASSWD=$(realpath ../dummy-passwd) - cat > $DUMMY_PASSWD <