Change:
<del> { lib, stdenv, fetchurl, unzip, darwin }: # TODO: consider unvendoring various dependencies (libpng, libjpeg, # libwebp, zlib, ...) </del> <ins> { lib, stdenv, fetchsvn, darwin, libtiff , libpng, zlib, libwebp, libraw, openexr, openjpeg , libjpeg, jxrlib, pkg-config }: </ins> stdenv.mkDerivation { <del> name = "freeimage-3.18.0"; </del> <ins> pname = "freeimage"; version = "unstable-2020-07-04"; </ins> <del> src = fetchurl { url = "mirror://sourceforge/freeimage/FreeImage3180.zip"; sha256 = "1z9qwi9mlq69d5jipr3v2jika2g0kszqdzilggm99nls5xl7j4zl"; </del> <ins> src = fetchsvn { url = "svn://svn.code.sf.net/p/freeimage/svn/"; rev = "1859"; sha256 = "1d94935aqbkb994nqkw7m8xcynyz9rm6k7k59igrbjak8b63qpi6"; </ins> }; <ins> sourceRoot = "svn-r1859/FreeImage/trunk"; </ins> <del> patches = lib.optional stdenv.isDarwin ./dylib.patch; buildInputs = [ unzip ] ++ lib.optional stdenv.isDarwin darwin.cctools; prePatch = if stdenv.isDarwin then '' sed -e 's/$(shell xcrun -find clang)/clang/g'  -e 's/$(shell xcrun -find clang++)/clang++/g'  -e "s|PREFIX = /usr/local|PREFIX = $out|"  -e 's|-Wl,-syslibroot $(MACOSX_SYSROOT)||g'  -e 's|-isysroot $(MACOSX_SYSROOT)||g'  -e 's|	install -d -m 755 -o root -g wheel $(INCDIR) $(INSTALLDIR)||'  -e 's| -m 644 -o root -g wheel||g'  -i ./Makefile.osx # Fix LibJXR performance timers sed 's|^SRCS = (.*)$|SRCS = 1 Source/LibJXR/image/sys/perfTimerANSI.c|' -i ./Makefile.srcs '' else '' sed -e s@/usr/@$out/@  -e 's@-o root -g root@@'  -e 's@ldconfig@echo not running ldconfig@'  -i Makefile.gnu Makefile.fip ''; </del> <ins> # Ensure that the bundled libraries are not used at all prePatch = "rm -rf Source/Lib* Source/OpenEXR Source/ZLib"; patches = [ ./unbundle.diff ]; nativeBuildInputs = [ pkg-config ] ++ lib.optional stdenv.isDarwin darwin.cctools; buildInputs = [ libtiff libtiff.dev_private libpng zlib libwebp libraw openexr openjpeg libjpeg libjpeg.dev_private jxrlib ]; </ins> postBuild = lib.optionalString (!stdenv.isDarwin) '' make -f Makefile.fip ''; <ins> INCDIR = "${placeholder "out"}/include"; INSTALLDIR = "${placeholder "out"}/lib"; </ins> preInstall = '' <del> mkdir -p $out/include $out/lib </del> <ins> mkdir -p $INCDIR $INSTALLDIR </ins> ''; postInstall = lib.optionalString (!stdenv.isDarwin) '' make -f Makefile.fip install <ins> '' + lib.optionalString stdenv.isDarwin '' ln -s $out/lib/libfreeimage.3.dylib $out/lib/libfreeimage.dylib </ins> ''; enableParallelBuilding = true;

Discussion:
Describe the bug I am trying to build for . is one giving me difficulty. Originally I filed an issue on : But the issue is instead with the libpng inside freeimage: Basically, libpng applies an incorrect ARM optimization to aarch64 that isn't actually available. From briefly looking at in nixpkgs, it seems that we patch with patches (and skimming that, it looks like it has a relevant aarch64 patch). So, my goal is to patch the vendored inside FreeImage, similar to how we patch itself. So far I've not had luck. I've tried with both the CRLF and LF patches from the 'apng' project and the regular patch used from the 'libpng-apng' project that is used in nixpkg's libpng. They all fail to apply and some complain about line endings, regardless of if I pipe the patch through dos2unix (or unix2dos) or not.
I seem to have fixed this by patching libpng inside of the freeimage source using the same patch as the derivation.. I'm just debating whether or not to allow it to be toggle-able as it is in the libpng derivation.
Hello, I'm a bot and I thank you in the name of the community for opening this issue. To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human. The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it. If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use or on the relevant files to find them. Lastly, you can always ask for help at or at .
still important to me
I marked this as stale due to inactivity. &rarr;
still important to me
You can close this I think