1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5
6 python3,
7 installShellFiles,
8 makeWrapper,
9 qt5,
10
11 advancecomp,
12 jpegoptim,
13 optipng,
14 pngcrush,
15}:
16
17let
18 pythonEnv = python3.withPackages (ps: with ps; [ pyqt5 ]);
19
20 binPath = lib.makeBinPath [
21 advancecomp
22 jpegoptim
23 optipng
24 pngcrush
25 ];
26in
27stdenv.mkDerivation {
28 pname = "trimage";
29 version = "1.0.7-dev";
30
31 src = fetchFromGitHub {
32 owner = "Kilian";
33 repo = "Trimage";
34 rev = "ad74684272a31eee6af289cc59fd90fd962d2806";
35 hash = "sha256-jdcGGTqr3f3Xnp6thYmASQYiZh9nagLUTmlFnJ5Hqmc=";
36 };
37
38 nativeBuildInputs = [
39 installShellFiles
40 makeWrapper
41 qt5.wrapQtAppsHook
42 ];
43
44 dontWrapQtApps = true;
45
46 installPhase = ''
47 runHook preInstall
48
49 mkdir $out
50 cp -R trimage $out
51
52 installManPage doc/trimage.1
53 install -Dm444 desktop/trimage.desktop -t $out/share/applications
54 install -Dm444 desktop/trimage.svg -t $out/share/icons/hicolor/scalable/apps
55
56 makeWrapper ${pythonEnv}/bin/python $out/bin/trimage \
57 --add-flags "$out/trimage/trimage.py" \
58 --prefix PATH : ${binPath} \
59 "''${qtWrapperArgs[@]}"
60
61 runHook postInstall
62 '';
63
64 meta = {
65 description = "Cross-platform tool for optimizing PNG and JPG files";
66 homepage = "https://github.com/Kilian/Trimage";
67 license = lib.licenses.mit;
68 mainProgram = "trimage";
69 maintainers = with lib.maintainers; [ tomasajt ];
70 };
71}