|
5 | 5 | , jdk |
6 | 6 | , quark-engine |
7 | 7 | , makeWrapper |
8 | | -, perl |
9 | 8 | , imagemagick |
10 | 9 | , makeDesktopItem |
11 | 10 | , copyDesktopItems |
12 | 11 | , desktopToDarwinBundle |
13 | 12 | }: |
14 | 13 |
|
15 | | -let |
| 14 | +stdenv.mkDerivation (finalAttrs: { |
16 | 15 | pname = "jadx"; |
17 | 16 | version = "1.4.7"; |
18 | 17 |
|
19 | 18 | src = fetchFromGitHub { |
20 | 19 | owner = "skylot"; |
21 | | - repo = pname; |
22 | | - rev = "v${version}"; |
| 20 | + repo = finalAttrs.pname; |
| 21 | + rev = "v${finalAttrs.version}"; |
23 | 22 | hash = "sha256-3t2e3WfH/ohkdGWlfV3t9oHJ1Q6YM6nSLOgmzgJEkls="; |
24 | 23 | }; |
25 | 24 |
|
26 | | - deps = stdenv.mkDerivation { |
27 | | - name = "${pname}-deps"; |
28 | | - inherit src; |
29 | | - |
30 | | - nativeBuildInputs = [ gradle jdk perl ]; |
31 | | - |
32 | | - buildPhase = '' |
33 | | - export GRADLE_USER_HOME=$(mktemp -d) |
34 | | - export JADX_VERSION=${version} |
35 | | - gradle --no-daemon jar |
36 | | -
|
37 | | - # Apparently, Gradle won't cache the `compileOnlyApi` dependency |
38 | | - # `org.jetbrains:annotations:22.0.0` which is defined in |
39 | | - # `io.github.skylot:raung-common`. To make it available in the |
40 | | - # output, we patch `build.gradle` and run Gradle again. |
41 | | - substituteInPlace build.gradle \ |
42 | | - --replace 'org.jetbrains:annotations:23.0.0' 'org.jetbrains:annotations:22.0.0' |
43 | | - gradle --no-daemon jar |
44 | | - ''; |
45 | | - |
46 | | - # Mavenize dependency paths |
47 | | - # 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 |
48 | | - installPhase = '' |
49 | | - find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \ |
50 | | - | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \ |
51 | | - | sh |
52 | | -
|
53 | | - # Work around okio-2.10.0 bug, fixed in 3.0. Remove "-jvm" from filename. |
54 | | - # https://github.com/square/okio/issues/954 |
55 | | - mv $out/com/squareup/okio/okio/2.10.0/okio{-jvm,}-2.10.0.jar |
56 | | - ''; |
57 | | - |
58 | | - outputHashMode = "recursive"; |
59 | | - outputHash = "sha256-QebPRmfLtXy4ZlyKeGC5XNzhMTsYI0X36My+nTFvQpM="; |
60 | | - }; |
61 | | -in stdenv.mkDerivation (finalAttrs: { |
62 | | - inherit pname version src; |
63 | | - |
64 | 25 | nativeBuildInputs = [ gradle jdk imagemagick makeWrapper copyDesktopItems ] |
65 | 26 | ++ lib.optionals stdenv.hostPlatform.isDarwin [ desktopToDarwinBundle ]; |
66 | 27 |
|
67 | 28 | # Otherwise, Gradle fails with `java.net.SocketException: Operation not permitted` |
68 | 29 | __darwinAllowLocalNetworking = true; |
69 | 30 |
|
70 | | - buildPhase = '' |
71 | | - # The installDist Gradle build phase tries to copy some dependency .jar |
72 | | - # files multiple times into the build directory. This ends up failing when |
73 | | - # the dependencies are read directly from the Nix store since they are not |
74 | | - # marked as chmod +w. To work around this, get a local copy of the |
75 | | - # dependency store, and give write permissions. |
76 | | - depsDir=$(mktemp -d) |
77 | | - cp -R ${deps}/* $depsDir |
78 | | - chmod -R u+w $depsDir |
79 | | -
|
80 | | - gradleInit=$(mktemp) |
81 | | - cat >$gradleInit <<EOF |
82 | | - gradle.projectsLoaded { |
83 | | - rootProject.allprojects { |
84 | | - buildscript { |
85 | | - repositories { |
86 | | - clear() |
87 | | - maven { url '$depsDir' } |
88 | | - } |
89 | | - } |
90 | | - repositories { |
91 | | - clear() |
92 | | - maven { url '$depsDir' } |
93 | | - } |
94 | | - } |
95 | | - } |
| 31 | + mitmCache = gradle.fetchDeps { |
| 32 | + inherit (finalAttrs) pname; |
| 33 | + data = ./deps.json; |
| 34 | + }; |
96 | 35 |
|
97 | | - settingsEvaluated { settings -> |
98 | | - settings.pluginManagement { |
99 | | - repositories { |
100 | | - maven { url '$depsDir' } |
101 | | - } |
102 | | - } |
103 | | - } |
104 | | - EOF |
| 36 | + preBuild = "export JADX_VERSION=${finalAttrs.version}"; |
105 | 37 |
|
106 | | - export GRADLE_USER_HOME=$(mktemp -d) |
107 | | - export JADX_VERSION=${version} |
108 | | - gradle --offline --no-daemon --info --init-script $gradleInit pack |
109 | | - ''; |
| 38 | + gradleBuildTask = "pack"; |
110 | 39 |
|
111 | 40 | installPhase = '' |
112 | 41 | runHook preInstall |
|
0 commit comments