about summary refs log tree commit diff
path: root/pkgs/applications/graphics/trimage/default.nix
blob: 6f38e22de14f693650eb974d7844bb493b19d107 (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
{ lib
, stdenv
, fetchFromGitHub

, python3
, installShellFiles
, makeWrapper
, wrapQtAppsHook

, advancecomp
, jpegoptim
, optipng
, pngcrush
}:

let
  pythonEnv = python3.withPackages (ps: with ps; [ pyqt5 ]);
  binPath = lib.makeBinPath [
    advancecomp
    jpegoptim
    optipng
    pngcrush
  ];
in
stdenv.mkDerivation {
  pname = "trimage";
  version = "1.0.7-dev";

  src = fetchFromGitHub {
    owner = "Kilian";
    repo = "Trimage";
    rev = "ad74684272a31eee6af289cc59fd90fd962d2806";
    hash = "sha256-jdcGGTqr3f3Xnp6thYmASQYiZh9nagLUTmlFnJ5Hqmc=";
  };

  nativeBuildInputs = [
    installShellFiles
    makeWrapper
    wrapQtAppsHook
  ];

  dontWrapQtApps = true;

  installPhase = ''
    runHook preInstall

    mkdir $out
    cp -R trimage $out

    installManPage doc/trimage.1
    install -Dm444 desktop/trimage.desktop -t $out/share/applications
    install -Dm444 desktop/trimage.svg -t $out/share/icons/hicolor/scalable/apps

    makeWrapper ${pythonEnv}/bin/python $out/bin/trimage \
          --add-flags "$out/trimage/trimage.py" \
          --prefix PATH : ${binPath} \
          "''${qtWrapperArgs[@]}"

    runHook postInstall
  '';

  meta = {
    description = "Cross-platform tool for optimizing PNG and JPG files";
    homepage = "https://github.com/Kilian/Trimage";
    license = lib.licenses.mit;
    mainProgram = "trimage";
    maintainers = with lib.maintainers; [ tomasajt ];
  };
}