1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, cmake
6}:
7
8stdenv.mkDerivation rec {
9 pname = "imagelol";
10 version = "0.2";
11
12 src = fetchFromGitHub {
13 owner = "MCRedstoner2004";
14 repo = pname;
15 rev = "v${version}";
16 sha256 = "0978zdrfj41jsqm78afyyd1l64iki9nwjvhd8ynii1b553nn4dmd";
17 fetchSubmodules = true;
18 };
19
20 patches = [
21 # upstream gcc-12 compatibility fix
22 (fetchpatch {
23 name = "gcc-12.patch";
24 url = "https://github.com/MCredstoner2004/ImageLOL/commit/013fb1f901d88f5fd21a896bfab47c7fff0737d7.patch";
25 hash = "sha256-RVaG2xbUqE4CxqI2lhvug2qihT6A8vN+pIfK58CXLDw=";
26 includes = [ "imagelol/ImageLOL.inl" ];
27 # change lib/ for imagelol
28 stripLen = 2;
29 extraPrefix = "imagelol/";
30 })
31 ];
32
33
34 # fix for case-sensitive filesystems
35 # https://github.com/MCredstoner2004/ImageLOL/issues/1
36 postPatch = ''
37 mv imagelol src
38 substituteInPlace CMakeLists.txt \
39 --replace 'add_subdirectory("imagelol")' 'add_subdirectory("src")'
40 '';
41
42 nativeBuildInputs = [ cmake ];
43
44 installPhase = ''
45 mkdir -p $out/bin
46 cp ./ImageLOL $out/bin
47 '';
48
49 cmakeFlags = lib.optional (stdenv.isDarwin && stdenv.isAarch64) "-DPNG_ARM_NEON=off";
50
51 meta = with lib; {
52 homepage = "https://github.com/MCredstoner2004/ImageLOL";
53 description = "Simple program to store a file into a PNG image";
54 license = licenses.mit;
55 maintainers = [ maintainers.ivar ];
56 platforms = platforms.unix;
57 };
58}