1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 libiconv,
6}:
7
8stdenv.mkDerivation {
9 pname = "leanify";
10 version = "unstable-2025-05-15";
11
12 src = fetchFromGitHub {
13 owner = "JayXon";
14 repo = "Leanify";
15 rev = "42770e600b32962e7110c24b5fcaa8c7c2144b17";
16 hash = "sha256-njfMR2DSKeVh+ZUewall7837E9JY3nhrTxO4LOY1pEo=";
17 };
18
19 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
20 substituteInPlace Makefile \
21 --replace-fail "-flto" "" \
22 --replace-fail "lib/LZMA/Alloc.o" "lib/LZMA/CpuArch.o lib/LZMA/Alloc.o" \
23 --replace-quiet "-Werror" ""
24 '';
25
26 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
27
28 doCheck = true;
29
30 checkPhase = ''
31 runHook preCheck
32
33 ./leanify /dev/null
34
35 runHook postCheck
36 '';
37
38 installPhase = ''
39 runHook preInstall
40
41 mkdir -p $out/bin
42 cp leanify $out/bin/
43
44 runHook postInstall
45 '';
46
47 meta = with lib; {
48 description = "Lightweight lossless file minifier/optimizer";
49 longDescription = ''
50 Leanify is a lightweight lossless file minifier/optimizer.
51 It removes unnecessary data (debug information, comments, metadata, etc.) and recompress the file to reduce file size.
52 It will not reduce image quality at all.
53 '';
54 homepage = "https://github.com/JayXon/Leanify";
55 changelog = "https://github.com/JayXon/Leanify/blob/master/CHANGELOG.md";
56 license = licenses.mit;
57 maintainers = [ maintainers.mynacol ];
58 platforms = platforms.all;
59 mainProgram = "leanify";
60 };
61}