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
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2024-09-19 14:19:46 +00:00
|
|
|
optionalDepsPath = lib.optional withPngcrush pngcrush
|
|
|
|
++ lib.optional withPngout pngout
|
|
|
|
++ lib.optional withAdvpng advancecomp
|
|
|
|
++ lib.optional withOptipng optipng
|
|
|
|
++ lib.optional withPngquant pngquant
|
|
|
|
++ lib.optional withOxipng oxipng
|
|
|
|
++ lib.optional withJhead jhead
|
|
|
|
++ lib.optional withJpegoptim jpegoptim
|
|
|
|
++ lib.optional withJpegrecompress jpeg-archive
|
|
|
|
++ lib.optional withJpegtran libjpeg
|
|
|
|
++ lib.optional withGifsicle gifsicle
|
|
|
|
++ lib.optional withSvgo svgo;
|
2023-04-12 12:48:02 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
disabledWorkersFlags = lib.optional (!withPngcrush) "--no-pngcrush"
|
|
|
|
++ lib.optional (!withPngout) "--no-pngout"
|
|
|
|
++ lib.optional (!withAdvpng) "--no-advpng"
|
|
|
|
++ lib.optional (!withOptipng) "--no-optipng"
|
|
|
|
++ lib.optional (!withPngquant) "--no-pngquant"
|
|
|
|
++ lib.optional (!withOxipng) "--no-oxipng"
|
|
|
|
++ lib.optional (!withJhead) "--no-jhead"
|
|
|
|
++ lib.optional (!withJpegoptim) "--no-jpegoptim"
|
|
|
|
++ lib.optional (!withJpegrecompress) "--no-jpegrecompress"
|
|
|
|
++ lib.optional (!withJpegtran) "--no-jpegtran"
|
|
|
|
++ lib.optional (!withGifsicle) "--no-gifsicle"
|
|
|
|
++ lib.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 \
|
2024-09-19 14:19:46 +00:00
|
|
|
--prefix PATH : ${lib.escapeShellArg (lib.makeBinPath optionalDepsPath)} \
|
2023-04-12 12:48:02 +00:00
|
|
|
--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;
|
2024-02-29 20:09:43 +00:00
|
|
|
mainProgram = "image_optim";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|