@@ -1,4 +1,4 @@
1−{ lib, stdenv, fetchFromGitHub, cmake, pkg-config
1+{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, pkg-config
22, libpng, libtiff, lcms2, jpylyzer
33, mj2Support ? true # MJ2 executables
44, jpwlLibSupport ? true # JPWL library & executables
@@ -10,8 +10,6 @@
1010, thirdPartySupport ? false # Third party libraries - OFF: only build when found, ON: always build
1111, testsSupport ? true
1212, jdk ? null
13−# Inherit generics
14−, branch, version, revision, sha256, patches ? [], extraFlags ? [], ...
1513}:
1614
1715assert jpipServerSupport -> jpipLibSupport && curl != null && fcgi != null;
@@ -23,18 +21,24 @@ let
2321 mkFlag = optSet: flag: "-D${flag}=${if optSet then "ON" else "OFF"}";
2422in
2523
26−stdenv.mkDerivation {
24+stdenv.mkDerivation rec {
2725 pname = "openjpeg";
28− inherit version;
26+ version = "2.4.0"; # don't forget to change passthru.incDir
2927
3028 src = fetchFromGitHub {
3129 owner = "uclouvain";
3230 repo = "openjpeg";
33− rev = revision;
34− inherit sha256;
31+ rev = "v${version}";
32+ sha256 = "143dvy5g6v6129lzvl0r8mrgva2fppkn0zl099qmi9yi9l9h7yyf";
3533 };
3634
37− inherit patches;
35+ patches = [
36+ ./fix-cmake-config-includedir.patch
37+ (fetchpatch {
38+ url = "https://patch-diff.githubusercontent.com/raw/uclouvain/openjpeg/pull/1321.patch";
39+ sha256 = "1cjpr76nf9g65nqkfnxnjzi3bv7ifbxpc74kxxibh58pzjlp6al8";
40+ })
41+ ];
3842
3943 outputs = [ "out" "dev" ];
4044
@@ -52,7 +56,9 @@ stdenv.mkDerivation {
5256 (mkFlag jp3dSupport "BUILD_JP3D")
5357 (mkFlag thirdPartySupport "BUILD_THIRDPARTY")
5458 (mkFlag testsSupport "BUILD_TESTING")
55− ] ++ extraFlags;
59+ "-DOPENJPEG_INSTALL_INCLUDE_DIR=${placeholder "dev"}/include/${passthru.incDir}"
60+ "-DOPENJPEG_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/${passthru.incDir}"
61+ ];
5662
5763 nativeBuildInputs = [ cmake pkg-config ];
5864
@@ -71,7 +77,7 @@ stdenv.mkDerivation {
7177 '';
7278
7379 passthru = {
74− incDir = "openjpeg-${branch}";
80+ incDir = "openjpeg-2.4";
7581 };
7682
7783 meta = with lib; {