1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 boost,
6 cmake,
7 nasm,
8 libpng,
9 nix-update-script,
10 versionCheckHook,
11}:
12
13stdenv.mkDerivation (finalAttrs: {
14 pname = "efficient-compression-tool";
15 version = "0.9.5";
16
17 src = fetchFromGitHub {
18 owner = "fhanau";
19 repo = "Efficient-Compression-Tool";
20 tag = "v${finalAttrs.version}";
21 hash = "sha256-mlqRDYwgLiB/mRaXkkPTCLiDGxTXqEgu5Nz5jhr1Hsg=";
22 fetchSubmodules = true;
23 };
24
25 # devendor libpng
26 postPatch = ''
27 substituteInPlace src/CMakeLists.txt \
28 --replace-fail 'if(EXISTS "''${CMAKE_SOURCE_DIR}/../.git" AND NOT EXISTS "''${CMAKE_SOURCE_DIR}/../src/libpng/README")' 'if(False)' \
29 --replace-fail 'file(COPY ''${CMAKE_SOURCE_DIR}/pngusr.h DESTINATION ''${CMAKE_SOURCE_DIR}/libpng/)' ""
30 substituteInPlace src/optipng/CMakeLists.txt \
31 --replace-fail 'set(PNG_BUILD_ZLIB ON CACHE BOOL "use custom zlib within libpng" FORCE)' "" \
32 --replace-fail 'add_subdirectory(../libpng libpng EXCLUDE_FROM_ALL)' "" \
33 --replace-fail 'png_static)' 'png)'
34 substituteInPlace src/optipng/image.h src/optipng/trans.h \
35 --replace-fail '#include "../libpng/png.h"' '#include <png.h>'
36 substituteInPlace src/optipng/opngreduc/opngreduc.h \
37 --replace-fail '#include "../../libpng/png.h"' '#include <png.h>'
38 '';
39
40 nativeBuildInputs = [
41 cmake
42 nasm
43 ];
44
45 buildInputs = [
46 boost
47 libpng
48 ];
49
50 cmakeDir = "../src";
51
52 cmakeFlags = [ "-DECT_FOLDER_SUPPORT=ON" ];
53
54 doInstallCheck = true;
55 nativeInstallCheckInputs = [ versionCheckHook ];
56 versionCheckProgram = "${placeholder "out"}/bin/${finalAttrs.meta.mainProgram}";
57 versionCheckProgramArg = "-help";
58
59 passthru = {
60 updateScript = nix-update-script { };
61 };
62
63 meta = {
64 description = "Fast and effective C++ file optimizer";
65 homepage = "https://github.com/fhanau/Efficient-Compression-Tool";
66 changelog = "https://github.com/fhanau/Efficient-Compression-Tool/releases/tag/${finalAttrs.version}";
67 license = lib.licenses.asl20;
68 maintainers = with lib.maintainers; [
69 jwillikers
70 lunik1
71 ];
72 platforms = lib.platforms.all;
73 mainProgram = "ect";
74 };
75})