mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 16:03:23 +00:00
4a7f99d55d
Part of: https://github.com/NixOS/nixpkgs/issues/108938 meta = with stdenv.lib; is a widely used pattern. We want to slowly remove the `stdenv.lib` indirection and encourage people to use `lib` directly. Thus let’s start with the meta field. This used a rewriting script to mostly automatically replace all occurances of this pattern, and add the `lib` argument to the package header if it doesn’t exist yet. The script in its current form is available at https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
104 lines
2.8 KiB
Nix
104 lines
2.8 KiB
Nix
{ lib, stdenv, fetchFromGitHub, gradle, jdk, makeWrapper, perl }:
|
|
|
|
let
|
|
pname = "jadx";
|
|
version = "1.2.0";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "skylot";
|
|
repo = pname;
|
|
rev = "v${version}";
|
|
sha256 = "1w1wc81mkjcsgjbrihbsphxkcmwnfnf555pmlsd2vs2a04nki01y";
|
|
};
|
|
|
|
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
|
|
'';
|
|
|
|
# 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
|
|
'';
|
|
|
|
outputHashAlgo = "sha256";
|
|
outputHashMode = "recursive";
|
|
outputHash = "05fsycpd90dbak2vgdpd9cz08liq5j78ag9ry9y1s62ld776g0hz";
|
|
};
|
|
in stdenv.mkDerivation {
|
|
inherit pname version src;
|
|
|
|
nativeBuildInputs = [ gradle jdk makeWrapper ];
|
|
|
|
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' }
|
|
}
|
|
}
|
|
}
|
|
|
|
settingsEvaluated { settings ->
|
|
settings.pluginManagement {
|
|
repositories {
|
|
maven { url '$depsDir' }
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
|
export JADX_VERSION=${version}
|
|
gradle --offline --no-daemon --info --init-script $gradleInit pack
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir $out $out/bin
|
|
cp -R build/jadx/lib $out
|
|
for prog in jadx jadx-gui; do
|
|
cp build/jadx/bin/$prog $out/bin
|
|
wrapProgram $out/bin/$prog --set JAVA_HOME ${jdk.home}
|
|
done
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "Dex to Java decompiler";
|
|
longDescription = ''
|
|
Command line and GUI tools for produce Java source code from Android Dex
|
|
and Apk files.
|
|
'';
|
|
license = licenses.asl20;
|
|
platforms = platforms.unix;
|
|
maintainers = with maintainers; [ delroth ];
|
|
};
|
|
}
|