about summary refs log tree commit diff
path: root/pkgs/by-name/de/densify/package.nix
blob: b4f2797ba94bca801cea2f051469e1e208058d54 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{
  fetchFromGitHub,
  lib,
  python3Packages,
  gtk3,
  gobject-introspection,
  wrapGAppsHook3,
  xorg,
  gnugrep,
  ghostscript,
}:

python3Packages.buildPythonApplication rec {
  pname = "densify";
  version = "0.3.2";
  format = "other";

  src = fetchFromGitHub {
    owner = "hkdb";
    repo = "Densify";
    rev = "refs/tags/v${version}";
    hash = "sha256-giFFy8HiSmnOqFKLyrPD1kTry8hMQxotEgD/u2FEMRY=";
  };

  postPatch = ''
    # Fix fail loading program icon from runtime path
    substituteInPlace densify \
      --replace-fail "/icon.png" "/../share/densify/icon.png"
  '';

  dependencies = with python3Packages; [ pygobject3 ];

  nativeBuildInputs = [
    gobject-introspection
    wrapGAppsHook3
  ];

  buildInputs = [ gtk3 ];

  preFixup = ''
    gappsWrapperArgs+=(
      --prefix PATH : "${
        lib.makeBinPath [
          ghostscript
          gnugrep
          xorg.xrandr
        ]
      }"
    )
  '';

  installPhase = ''
    runHook preInstall

    install -Dm755 -t $out/bin densify
    install -Dm644 -t $out/share/applications densify.desktop
    install -Dm644 -t $out/share/densify desktop-icon.png icon.png

    runHook postInstall
  '';

  postFixup = ''
    substituteInPlace $out/share/applications/densify.desktop \
      --replace-fail "/opt/Densify/densify" "densify" \
      --replace-fail "Path=/opt/Densify/" "Path=$out/bin/" \
      --replace-fail "/opt/Densify/desktop-icon.png" "$out/share/densify/desktop-icon.png"
  '';

  meta = {
    description = "Compress PDF files with Ghostscript";
    homepage = "https://github.com/hkdb/Densify";
    changelog = "https://github.com/hkdb/Densify/blob/${src.rev}/README.md";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ onny ];
    platforms = lib.platforms.all;
  };
}