summary refs log tree commit diff
path: root/pkgs/applications/graphics/image_optim/default.nix
blob: 385f9825e46f70517aca842e0cbcf6db143ee5a7 (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
{ lib, bundlerApp, bundlerUpdateScript, makeWrapper,
  withPngcrush ? true,       pngcrush ? null,
  withPngout ? true,         pngout ? null,
  withAdvpng ? true,         advancecomp ? null,
  withOptipng ? true,        optipng ? null,
  withPngquant ? true,       pngquant ? null,
  withJhead ? true,          jhead ? null,
  withJpegoptim ? true,      jpegoptim ? null,
  withJpegrecompress ? true, jpeg-archive ? null,
  withJpegtran ? true,       libjpeg ? null,
  withGifsicle ? true,       gifsicle ? null,
  withSvgo ? true,           svgo ? null
}:

assert withPngcrush       -> pngcrush != null;
assert withPngout         -> pngout != null;
assert withAdvpng         -> advancecomp != null;
assert withOptipng        -> optipng != null;
assert withPngquant       -> pngquant != null;
assert withJhead          -> jhead != null;
assert withJpegoptim      -> jpegoptim != null;
assert withJpegrecompress -> jpeg-archive != null;
assert withJpegtran       -> libjpeg != null;
assert withGifsicle       -> gifsicle != null;
assert withSvgo           -> svgo != null;

with lib;

let
  optionalDepsPath = []
    ++ optional withPngcrush pngcrush
    ++ optional withPngout pngout
    ++ optional withAdvpng advancecomp
    ++ optional withOptipng optipng
    ++ optional withPngquant pngquant
    ++ optional withJhead jhead
    ++ optional withJpegoptim jpegoptim
    ++ optional withJpegrecompress jpeg-archive
    ++ optional withJpegtran libjpeg
    ++ optional withGifsicle gifsicle
    ++ optional withSvgo svgo;
in

bundlerApp {
  pname = "image_optim";
  gemdir = ./.;

  exes = [ "image_optim" ];

  buildInputs = [ makeWrapper ];

  postBuild = ''
    wrapProgram $out/bin/image_optim \
      --prefix PATH : ${makeBinPath optionalDepsPath}
  '';

  passthru.updateScript = bundlerUpdateScript "image_optim";

  meta = with lib; {
    description = "Command line tool and ruby interface to optimize (lossless compress, optionally lossy) jpeg, png, gif and svg images using external utilities (advpng, gifsicle, jhead, jpeg-recompress, jpegoptim, jpegrescan, jpegtran, optipng, pngcrush, pngout, pngquant, svgo)";
    homepage    = https://github.com/toy/image_optim;
    license     = licenses.mit;
    maintainers = with maintainers; [ srghma nicknovitski ];
    platforms   = platforms.all;
  };
}