nixpkgs/pkgs/tools/security/jd-gui/default.nix

110 lines
3.0 KiB
Nix
Raw Normal View History

2020-11-27 12:46:36 +00:00
{ stdenv, fetchFromGitHub, jre, jdk, gradle_5, makeDesktopItem, copyDesktopItems, perl, writeText, runtimeShell }:
let
2019-12-12 03:19:00 +00:00
pname = "jd-gui";
2020-01-10 03:20:32 +00:00
version = "1.6.6";
2019-12-12 03:19:00 +00:00
src = fetchFromGitHub {
owner = "java-decompiler";
repo = pname;
rev = "v${version}";
2020-01-10 03:20:32 +00:00
sha256 = "010bd3q2m4jy4qz5ahdx86b5f558s068gbjlbpdhq3bhh4yrjy20";
};
2018-06-26 16:48:07 +00:00
deps = stdenv.mkDerivation {
2019-12-12 03:19:00 +00:00
name = "${pname}-deps";
2018-06-26 16:48:07 +00:00
inherit src;
2019-12-12 03:19:00 +00:00
2020-07-04 20:16:53 +00:00
nativeBuildInputs = [ jdk perl gradle_5 ];
2018-06-26 16:48:07 +00:00
buildPhase = ''
export GRADLE_USER_HOME=$(mktemp -d);
gradle --no-daemon jar
2018-06-26 16:48:07 +00:00
'';
2018-06-26 16:48:07 +00:00
# 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";
2020-01-10 03:20:32 +00:00
outputHash = "1qil12s0daxpxj5xj5dj6s2k89is0kiir2vcafkm3lasc41acmk3";
2018-06-26 16:48:07 +00:00
};
# Point to our local deps repo
gradleInit = writeText "init.gradle" ''
logger.lifecycle 'Replacing Maven repositories with ${deps}...'
gradle.projectsLoaded {
rootProject.allprojects {
buildscript {
repositories {
clear()
maven { url '${deps}' }
}
}
repositories {
clear()
maven { url '${deps}' }
}
}
}
'';
2020-11-27 12:46:36 +00:00
desktopItem = makeDesktopItem {
2018-06-26 16:48:07 +00:00
name = "jd-gui";
2020-11-27 12:46:36 +00:00
exec = "jd-gui %F";
2018-06-26 16:48:07 +00:00
icon = "jd-gui";
comment = "Java Decompiler JD-GUI";
desktopName = "JD-GUI";
genericName = "Java Decompiler";
2019-12-12 03:19:00 +00:00
mimeType = "application/java;application/java-vm;application/java-archive";
2018-06-26 16:48:07 +00:00
categories = "Development;Debugger;";
2019-12-12 03:19:00 +00:00
extraEntries="StartupWMClass=org-jd-gui-App";
2018-06-26 16:48:07 +00:00
};
2019-12-12 03:19:00 +00:00
in stdenv.mkDerivation rec {
inherit pname version src;
name = "${pname}-${version}";
2018-06-26 16:48:07 +00:00
2020-11-27 12:46:36 +00:00
nativeBuildInputs = [ jdk gradle_5 copyDesktopItems ];
2018-06-26 16:48:07 +00:00
buildPhase = ''
export GRADLE_USER_HOME=$(mktemp -d)
gradle --offline --no-daemon --info --init-script ${gradleInit} jar
2018-06-26 16:48:07 +00:00
'';
installPhase = let
jar = "$out/share/jd-gui/${name}.jar";
in ''
2020-11-27 12:46:36 +00:00
runHook preInstall
2018-06-26 16:48:07 +00:00
mkdir -p $out/bin $out/share/{jd-gui,icons/hicolor/128x128/apps}
cp build/libs/${name}.jar ${jar}
cp src/linux/resources/jd_icon_128.png $out/share/icons/hicolor/128x128/apps/jd-gui.png
cat > $out/bin/jd-gui <<EOF
#!${runtimeShell}
2018-06-26 16:48:07 +00:00
export JAVA_HOME=${jre}
2019-12-12 03:19:00 +00:00
exec ${jre}/bin/java -jar ${jar} "\$@"
2018-06-26 16:48:07 +00:00
EOF
chmod +x $out/bin/jd-gui
2020-11-27 12:46:36 +00:00
runHook postInstall
'';
2020-11-27 12:46:36 +00:00
desktopItems = [ desktopItem ];
2018-06-26 16:48:07 +00:00
meta = with stdenv.lib; {
description = "Fast Java Decompiler with powerful GUI";
2019-12-12 03:19:00 +00:00
homepage = "https://java-decompiler.github.io/";
2018-06-26 16:48:07 +00:00
license = licenses.gpl3;
platforms = platforms.unix;
maintainers = [ maintainers.thoughtpolice ];
};
}