diff --git a/pkgs/by-name/le/lerc/package.nix b/pkgs/by-name/le/lerc/package.nix index 08a7cb63afbf..1443ce855449 100644 --- a/pkgs/by-name/le/lerc/package.nix +++ b/pkgs/by-name/le/lerc/package.nix @@ -1,6 +1,7 @@ { lib, stdenv, + buildPackages, fetchFromGitHub, fetchpatch, cmake, @@ -23,14 +24,28 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-IHY9QtNYsxPz/ksxRMZGHleT+/bawfTYNVRSTAuYQ7Y="; }; - patches = [ - # https://github.com/Esri/lerc/pull/227 - (fetchpatch { - name = "use-cmake-install-full-dir.patch"; - url = "https://github.com/Esri/lerc/commit/5462ca7f7dfb38c65e16f5abfd96873af177a0f8.patch"; - hash = "sha256-qaNR3QwLe0AB6vu1nXOh9KhlPdWM3DmgCJj4d0VdOUk="; - }) - ]; + # Required to get the freebsd-ports patch to apply. + # There seem to be inconsistent line endings in this project - just converting the patch doesn't work + prePatch = lib.optionalString stdenv.hostPlatform.isFreeBSD '' + ${buildPackages.dos2unix}/bin/dos2unix src/LercLib/fpl_EsriHuffman.cpp src/LercLib/fpl_Lerc2Ext.cpp + ''; + + patches = + [ + # https://github.com/Esri/lerc/pull/227 + (fetchpatch { + name = "use-cmake-install-full-dir.patch"; + url = "https://github.com/Esri/lerc/commit/5462ca7f7dfb38c65e16f5abfd96873af177a0f8.patch"; + hash = "sha256-qaNR3QwLe0AB6vu1nXOh9KhlPdWM3DmgCJj4d0VdOUk="; + }) + ] + ++ lib.optionals stdenv.hostPlatform.isFreeBSD [ + (fetchpatch { + url = "https://raw.githubusercontent.com/freebsd/freebsd-ports/ee9e39ceb1af729ac33854b5f3de652cb5ce0eca/graphics/lerc/files/patch-_assert"; + hash = "sha256-agvGqgIsKS8v43UZdTVxDRDGbZdj2+AzKoQONvQumB4="; + extraPrefix = ""; + }) + ]; nativeBuildInputs = [ cmake