diff options
Diffstat (limited to 'pkgs/tools/security/jadx/default.nix')
-rw-r--r-- | pkgs/tools/security/jadx/default.nix | 138 |
1 files changed, 42 insertions, 96 deletions
diff --git a/pkgs/tools/security/jadx/default.nix b/pkgs/tools/security/jadx/default.nix index df7bb1ca839cd..07c9a4a6c29b7 100644 --- a/pkgs/tools/security/jadx/default.nix +++ b/pkgs/tools/security/jadx/default.nix @@ -1,112 +1,52 @@ -{ lib -, stdenv -, fetchFromGitHub -, gradle -, jdk -, quark-engine -, makeWrapper -, perl -, imagemagick -, makeDesktopItem -, copyDesktopItems -, desktopToDarwinBundle +{ + lib, + stdenv, + fetchFromGitHub, + gradle, + jdk, + quark-engine, + makeBinaryWrapper, + imagemagick, + makeDesktopItem, + copyDesktopItems, + desktopToDarwinBundle, }: -let +stdenv.mkDerivation (finalAttrs: { pname = "jadx"; - version = "1.4.7"; + version = "1.5.0"; src = fetchFromGitHub { owner = "skylot"; - repo = pname; - rev = "v${version}"; - hash = "sha256-3t2e3WfH/ohkdGWlfV3t9oHJ1Q6YM6nSLOgmzgJEkls="; + repo = "jadx"; + rev = "v${finalAttrs.version}"; + hash = "sha256-+F+PHAd1+FmdAlQkjYDBsUYCUzKXG19ZUEorfvBUEg0="; }; - deps = stdenv.mkDerivation { - name = "${pname}-deps"; - inherit src; - - nativeBuildInputs = [ gradle jdk perl ]; - - buildPhase = '' - export GRADLE_USER_HOME=$(mktemp -d) - export JADX_VERSION=${version} - gradle --no-daemon jar - - # Apparently, Gradle won't cache the `compileOnlyApi` dependency - # `org.jetbrains:annotations:22.0.0` which is defined in - # `io.github.skylot:raung-common`. To make it available in the - # output, we patch `build.gradle` and run Gradle again. - substituteInPlace build.gradle \ - --replace 'org.jetbrains:annotations:23.0.0' 'org.jetbrains:annotations:22.0.0' - gradle --no-daemon jar - ''; - - # Mavenize dependency paths - # e.g. org.codehaus.groovy/groovy/2.4.0/{hash}/groovy-2.4.0.jar -> org/codehaus/groovy/groovy/2.4.0/groovy-2.4.0.jar - installPhase = '' - find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \ - | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \ - | sh - - # Work around okio-2.10.0 bug, fixed in 3.0. Remove "-jvm" from filename. - # https://github.com/square/okio/issues/954 - mv $out/com/squareup/okio/okio/2.10.0/okio{-jvm,}-2.10.0.jar - ''; - - outputHashMode = "recursive"; - outputHash = "sha256-QebPRmfLtXy4ZlyKeGC5XNzhMTsYI0X36My+nTFvQpM="; - }; -in stdenv.mkDerivation (finalAttrs: { - inherit pname version src; + patches = [ + # Remove use of launch4j - contains platform binaries not able to be cached by mitmCache + ./no-native-deps.diff + ]; - nativeBuildInputs = [ gradle jdk imagemagick makeWrapper copyDesktopItems ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ desktopToDarwinBundle ]; + nativeBuildInputs = [ + gradle + jdk + imagemagick + makeBinaryWrapper + copyDesktopItems + ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ desktopToDarwinBundle ]; # Otherwise, Gradle fails with `java.net.SocketException: Operation not permitted` __darwinAllowLocalNetworking = true; - buildPhase = '' - # The installDist Gradle build phase tries to copy some dependency .jar - # files multiple times into the build directory. This ends up failing when - # the dependencies are read directly from the Nix store since they are not - # marked as chmod +w. To work around this, get a local copy of the - # dependency store, and give write permissions. - depsDir=$(mktemp -d) - cp -R ${deps}/* $depsDir - chmod -R u+w $depsDir - - gradleInit=$(mktemp) - cat >$gradleInit <<EOF - gradle.projectsLoaded { - rootProject.allprojects { - buildscript { - repositories { - clear() - maven { url '$depsDir' } - } - } - repositories { - clear() - maven { url '$depsDir' } - } - } - } + mitmCache = gradle.fetchDeps { + pname = "jadx"; + data = ./deps.json; + }; - settingsEvaluated { settings -> - settings.pluginManagement { - repositories { - maven { url '$depsDir' } - } - } - } - EOF + preBuild = "export JADX_VERSION=${finalAttrs.version}"; - export GRADLE_USER_HOME=$(mktemp -d) - export JADX_VERSION=${version} - gradle --offline --no-daemon --info --init-script $gradleInit pack - ''; + gradleBuildTask = "pack"; installPhase = '' runHook preInstall @@ -140,22 +80,28 @@ in stdenv.mkDerivation (finalAttrs: { exec = "jadx-gui"; icon = "jadx"; comment = finalAttrs.meta.description; - categories = [ "Development" "Utility" ]; + categories = [ + "Development" + "Utility" + ]; }) ]; meta = with lib; { + changelog = "https://github.com/skylot/jadx/releases/tag/v${finalAttrs.version}"; description = "Dex to Java decompiler"; + homepage = "https://github.com/skylot/jadx"; longDescription = '' Command line and GUI tools for produce Java source code from Android Dex and Apk files. ''; sourceProvenance = with sourceTypes; [ fromSource - binaryBytecode # deps + binaryBytecode # deps ]; license = licenses.asl20; platforms = platforms.unix; + mainProgram = "jadx-gui"; maintainers = with maintainers; [ emilytrau ]; }; }) |