nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitLab,
5 gradle_8,
6 jre_headless,
7 jre_minimal,
8 runtimeShell,
9}:
10let
11 # "Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0."
12 gradle = gradle_8;
13
14 jre = jre_minimal.override {
15 modules = [
16 "java.base"
17 "java.desktop"
18 ];
19 jdk = jre_headless;
20 };
21in
22stdenv.mkDerivation rec {
23 pname = "pdftk";
24 version = "3.3.3";
25
26 src = fetchFromGitLab {
27 owner = "pdftk-java";
28 repo = "pdftk";
29 rev = "v${version}";
30 hash = "sha256-ciKotTHSEcITfQYKFZ6sY2LZnXGChBJy0+eno8B3YHY=";
31 };
32
33 nativeBuildInputs = [ gradle ];
34
35 mitmCache = gradle.fetchDeps {
36 inherit pname;
37 data = ./deps.json;
38 };
39
40 __darwinAllowLocalNetworking = true;
41
42 gradleFlags = [ "-Dfile.encoding=utf-8" ];
43
44 gradleBuildTask = "shadowJar";
45
46 installPhase = ''
47 mkdir -p $out/{bin,share/pdftk,share/man/man1}
48 cp build/libs/pdftk-all.jar $out/share/pdftk
49
50 cat << EOF > $out/bin/pdftk
51 #!${runtimeShell}
52 exec ${jre}/bin/java -jar "$out/share/pdftk/pdftk-all.jar" "\$@"
53 EOF
54 chmod a+x "$out/bin/pdftk"
55
56 cp ${src}/pdftk.1 $out/share/man/man1
57 '';
58
59 meta = with lib; {
60 description = "Command-line tool for working with PDFs";
61 homepage = "https://gitlab.com/pdftk-java/pdftk";
62 sourceProvenance = with sourceTypes; [
63 fromSource
64 binaryBytecode # deps
65 ];
66 license = licenses.gpl2Plus;
67 maintainers = with maintainers; [
68 raskin
69 averelld
70 ];
71 platforms = platforms.unix;
72 mainProgram = "pdftk";
73 };
74}