2020-04-24 23:36:52 +00:00
|
|
|
{ lib, bundlerApp, bundlerUpdateScript, makeWrapper,
|
2022-05-18 14:49:53 +00:00
|
|
|
withPngcrush ? true, pngcrush,
|
2023-04-12 12:48:02 +00:00
|
|
|
withPngout ? false, pngout, # disabled by default because it's unfree
|
2022-05-18 14:49:53 +00:00
|
|
|
withAdvpng ? true, advancecomp,
|
|
|
|
withOptipng ? true, optipng,
|
|
|
|
withPngquant ? true, pngquant,
|
2023-04-12 12:48:02 +00:00
|
|
|
withOxipng ? true, oxipng,
|
2022-05-18 14:49:53 +00:00
|
|
|
withJhead ? true, jhead,
|
|
|
|
withJpegoptim ? true, jpegoptim,
|
|
|
|
withJpegrecompress ? true, jpeg-archive,
|
|
|
|
withJpegtran ? true, libjpeg,
|
|
|
|
withGifsicle ? true, gifsicle,
|
|
|
|
withSvgo ? true, svgo
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2023-04-12 12:48:02 +00:00
|
|
|
optionalDepsPath = optional withPngcrush pngcrush
|
2020-04-24 23:36:52 +00:00
|
|
|
++ optional withPngout pngout
|
|
|
|
++ optional withAdvpng advancecomp
|
|
|
|
++ optional withOptipng optipng
|
|
|
|
++ optional withPngquant pngquant
|
2023-04-12 12:48:02 +00:00
|
|
|
++ optional withOxipng oxipng
|
2020-04-24 23:36:52 +00:00
|
|
|
++ optional withJhead jhead
|
|
|
|
++ optional withJpegoptim jpegoptim
|
|
|
|
++ optional withJpegrecompress jpeg-archive
|
|
|
|
++ optional withJpegtran libjpeg
|
|
|
|
++ optional withGifsicle gifsicle
|
|
|
|
++ optional withSvgo svgo;
|
2023-04-12 12:48:02 +00:00
|
|
|
|
|
|
|
disabledWorkersFlags = optional (!withPngcrush) "--no-pngcrush"
|
|
|
|
++ optional (!withPngout) "--no-pngout"
|
|
|
|
++ optional (!withAdvpng) "--no-advpng"
|
|
|
|
++ optional (!withOptipng) "--no-optipng"
|
|
|
|
++ optional (!withPngquant) "--no-pngquant"
|
|
|
|
++ optional (!withOxipng) "--no-oxipng"
|
|
|
|
++ optional (!withJhead) "--no-jhead"
|
|
|
|
++ optional (!withJpegoptim) "--no-jpegoptim"
|
|
|
|
++ optional (!withJpegrecompress) "--no-jpegrecompress"
|
|
|
|
++ optional (!withJpegtran) "--no-jpegtran"
|
|
|
|
++ optional (!withGifsicle) "--no-gifsicle"
|
|
|
|
++ optional (!withSvgo) "--no-svgo";
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
bundlerApp {
|
|
|
|
pname = "image_optim";
|
|
|
|
gemdir = ./.;
|
|
|
|
|
|
|
|
exes = [ "image_optim" ];
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postBuild = ''
|
|
|
|
wrapProgram $out/bin/image_optim \
|
2023-04-12 12:48:02 +00:00
|
|
|
--prefix PATH : ${lib.escapeShellArg (makeBinPath optionalDepsPath)} \
|
|
|
|
--add-flags "${lib.concatStringsSep " " disabledWorkersFlags}"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.updateScript = bundlerUpdateScript "image_optim";
|
|
|
|
|
|
|
|
meta = with lib; {
|
2023-04-12 12:48:02 +00:00
|
|
|
description = "Optimize images using multiple utilities";
|
|
|
|
longDescription = ''
|
|
|
|
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, oxipng, pngcrush, pngout, pngquant, svgo)
|
|
|
|
'';
|
|
|
|
homepage = "https://github.com/toy/image_optim";
|
|
|
|
license = licenses.mit;
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = with maintainers; [ srghma nicknovitski ];
|
2023-04-12 12:48:02 +00:00
|
|
|
platforms = platforms.all;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|