1{
2 fetchFromGitHub,
3 lib,
4 python3Packages,
5 gtk3,
6 gobject-introspection,
7 wrapGAppsHook3,
8 xorg,
9 gnugrep,
10 ghostscript,
11 libnotify,
12}:
13
14python3Packages.buildPythonApplication rec {
15 pname = "densify";
16 version = "0.3.2";
17 format = "other";
18
19 src = fetchFromGitHub {
20 owner = "hkdb";
21 repo = "Densify";
22 tag = "v${version}";
23 hash = "sha256-giFFy8HiSmnOqFKLyrPD1kTry8hMQxotEgD/u2FEMRY=";
24 };
25
26 postPatch = ''
27 # Fix fail loading program icon from runtime path
28 substituteInPlace densify \
29 --replace-fail "/icon.png" "/../share/densify/icon.png"
30 '';
31
32 dependencies = with python3Packages; [ pygobject3 ];
33
34 nativeBuildInputs = [
35 gobject-introspection
36 wrapGAppsHook3
37 ];
38
39 buildInputs = [ gtk3 ];
40
41 preFixup = ''
42 gappsWrapperArgs+=(
43 --prefix PATH : "${
44 lib.makeBinPath [
45 ghostscript
46 gnugrep
47 xorg.xrandr
48 libnotify
49 ]
50 }"
51 )
52 '';
53
54 installPhase = ''
55 runHook preInstall
56
57 install -Dm755 -t $out/bin densify
58 install -Dm644 -t $out/share/applications densify.desktop
59 install -Dm644 -t $out/share/densify desktop-icon.png icon.png
60
61 runHook postInstall
62 '';
63
64 postFixup = ''
65 substituteInPlace $out/share/applications/densify.desktop \
66 --replace-fail "/opt/Densify/densify" "densify" \
67 --replace-fail "Path=/opt/Densify/" "Path=$out/bin/" \
68 --replace-fail "/opt/Densify/desktop-icon.png" "$out/share/densify/desktop-icon.png"
69 '';
70
71 meta = {
72 description = "Compress PDF files with Ghostscript";
73 homepage = "https://github.com/hkdb/Densify";
74 changelog = "https://github.com/hkdb/Densify/blob/${src.rev}/README.md";
75 license = lib.licenses.mit;
76 maintainers = with lib.maintainers; [ onny ];
77 platforms = lib.platforms.all;
78 };
79}