1 { lib, stdenv, fetchFromGitLab, gradle, jre, perl, writeText, runtimeShell }:
7 src = fetchFromGitLab {
11 hash = "sha256-ciKotTHSEcITfQYKFZ6sY2LZnXGChBJy0+eno8B3YHY=";
14 deps = stdenv.mkDerivation {
15 pname = "${pname}-deps";
18 nativeBuildInputs = [ gradle perl ];
21 export GRADLE_USER_HOME=$(mktemp -d)
22 gradle -Dfile.encoding=utf-8 shadowJar;
25 # Mavenize dependency paths
26 # 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
28 find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \
29 | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
33 outputHashAlgo = "sha256";
34 outputHashMode = "recursive";
35 outputHash = "sha256-Mx5CdiRxuql22kbLozzr9Rs2E2Svzg2zN1138Xa0pMc=";
38 # Point to our local deps repo
39 gradleInit = writeText "init.gradle" ''
40 logger.lifecycle 'Replacing Maven repositories with ${deps}...'
41 gradle.projectsLoaded {
42 rootProject.allprojects {
46 maven { url '${deps}' }
51 maven { url '${deps}' }
56 settingsEvaluated { settings ->
57 settings.pluginManagement {
59 maven { url '${deps}' }
65 in stdenv.mkDerivation rec {
66 inherit pname version src;
68 nativeBuildInputs = [ gradle ];
71 export GRADLE_USER_HOME=$(mktemp -d)
72 gradle --offline --no-daemon --info --init-script ${gradleInit} shadowJar
76 mkdir -p $out/{bin,share/pdftk,share/man/man1}
77 cp build/libs/pdftk-all.jar $out/share/pdftk
79 cat << EOF > $out/bin/pdftk
81 exec ${jre}/bin/java -jar "$out/share/pdftk/pdftk-all.jar" "\$@"
83 chmod a+x "$out/bin/pdftk"
85 cp ${src}/pdftk.1 $out/share/man/man1
89 description = "Command-line tool for working with PDFs";
90 homepage = "https://gitlab.com/pdftk-java/pdftk";
91 sourceProvenance = with sourceTypes; [
95 license = licenses.gpl2Plus;
96 maintainers = with maintainers; [ raskin averelld ];
97 platforms = platforms.unix;