2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv, fetchFromGitLab, gradle, jre, perl, writeText, runtimeShell }:
|
2010-06-02 08:21:49 +00:00
|
|
|
|
2019-12-11 22:17:39 +00:00
|
|
|
let
|
|
|
|
pname = "pdftk";
|
2020-11-30 15:38:16 +00:00
|
|
|
version = "3.2.1";
|
2010-06-02 08:21:49 +00:00
|
|
|
|
2019-12-11 22:17:39 +00:00
|
|
|
src = fetchFromGitLab {
|
|
|
|
owner = "pdftk-java";
|
|
|
|
repo = "pdftk";
|
|
|
|
rev = "v${version}";
|
2020-11-30 15:38:16 +00:00
|
|
|
sha256 = "056db8rjczdfkq7fm3bv5g15y042rc9hb4zh5qccjrdw630vk9y4";
|
2010-06-02 08:21:49 +00:00
|
|
|
};
|
|
|
|
|
2019-12-11 22:17:39 +00:00
|
|
|
deps = stdenv.mkDerivation {
|
|
|
|
pname = "${pname}-deps";
|
|
|
|
inherit src version;
|
2010-06-02 08:21:49 +00:00
|
|
|
|
2020-11-30 15:38:16 +00:00
|
|
|
nativeBuildInputs = [ gradle perl ];
|
2016-08-29 09:02:03 +00:00
|
|
|
|
2019-12-11 22:17:39 +00:00
|
|
|
buildPhase = ''
|
|
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
|
|
|
gradle -Dfile.encoding=utf-8 shadowJar;
|
|
|
|
'';
|
|
|
|
|
|
|
|
# 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-11-30 15:38:16 +00:00
|
|
|
outputHash = "0p59myc5m3ds7fh0zdz3n7l7hx6dj8bpyqxzlhdrqybsyxwpw4w3";
|
2019-12-11 22:17:39 +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}' }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
settingsEvaluated { settings ->
|
|
|
|
settings.pluginManagement {
|
|
|
|
repositories {
|
|
|
|
maven { url '${deps}' }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-11-15 22:16:01 +00:00
|
|
|
'';
|
2010-06-02 08:21:49 +00:00
|
|
|
|
2019-12-11 22:17:39 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
inherit pname version src;
|
2010-06-02 08:21:49 +00:00
|
|
|
|
2020-11-30 15:38:16 +00:00
|
|
|
nativeBuildInputs = [ gradle ];
|
2019-12-11 22:17:39 +00:00
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
|
|
|
gradle --offline --no-daemon --info --init-script ${gradleInit} shadowJar
|
2010-06-02 08:21:49 +00:00
|
|
|
'';
|
|
|
|
|
2019-12-11 22:17:39 +00:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/{bin,share/pdftk,share/man/man1}
|
2020-11-30 15:38:16 +00:00
|
|
|
cp build/libs/pdftk-all.jar $out/share/pdftk
|
2019-12-11 22:17:39 +00:00
|
|
|
|
|
|
|
cat << EOF > $out/bin/pdftk
|
|
|
|
#!${runtimeShell}
|
2020-11-30 15:38:16 +00:00
|
|
|
exec ${jre}/bin/java -jar "$out/share/pdftk/pdftk-all.jar" "\$@"
|
2019-12-11 22:17:39 +00:00
|
|
|
EOF
|
|
|
|
chmod a+x "$out/bin/pdftk"
|
|
|
|
|
|
|
|
cp ${src}/pdftk.1 $out/share/man/man1
|
|
|
|
'';
|
2014-11-15 22:16:01 +00:00
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2019-12-11 22:17:39 +00:00
|
|
|
description = "Command-line tool for working with PDFs";
|
|
|
|
homepage = "https://gitlab.com/pdftk-java/pdftk";
|
2020-12-02 09:07:23 +00:00
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
maintainers = with maintainers; [ raskin averelld ];
|
|
|
|
platforms = platforms.unix;
|
2010-06-02 08:21:49 +00:00
|
|
|
};
|
|
|
|
}
|