Change:
I tried building openjpeg as a dependency when using on Mac OS X, and it failed on trying to run javac. Nevertheless, its derivation seemed to define (long line follows). The package built successfully after I installed an external JDK. It seems that for some strange reason the build script is ignoring the option.
Should fix this. JPIP builds a java component, but the cmake script does not require for
Thanks for the quick reaction! I will try the fix soon!

Discussion:
<del> { callPackage, fetchurl, ... } @ args: </del> <ins> { callPackage, ... } @ args: </ins> callPackage ./generic.nix (args // rec { version = "${branch}.2"; branch = "1.5"; <del> src = fetchurl { url = "mirror://gentoo/distfiles/openjpeg-${version}.tar.gz"; sha256 = "11waq9w215zvzxrpv40afyd18qf79mxc28fda80bm3ax98cpppqm"; }; </del> <ins> sha256 = "11waq9w215zvzxrpv40afyd18qf79mxc28fda80bm3ax98cpppqm"; </ins> })

<del> { callPackage, fetchurl, ... } @ args: callPackage ./generic.nix (args // rec { version = "${branch}.0.1"; branch = "2"; src = fetchurl { url = "mirror://sourceforge/openjpeg.mirror/openjpeg-${version}.tar.gz"; sha256 = "1c2xc3nl2mg511b63rk7hrckmy14681p1m44mzw3n1fyqnjm0b0z"; }; }) </del>

<ins> { callPackage, ... } @ args: callPackage ./generic.nix (args // rec { version = "${branch}.0.1"; branch = "2"; sha256 = "1c2xc3nl2mg511b63rk7hrckmy14681p1m44mzw3n1fyqnjm0b0z"; }) </ins>

<del> { callPackage, fetchurl, ... } @ args: </del> <ins> { callPackage, ... } @ args: </ins> callPackage ./generic.nix (args // rec { version = "${branch}.0"; branch = "2.1"; <del> src = fetchurl { url = "mirror://gentoo/distfiles/openjpeg-${version}.tar.gz"; sha256 = "00zzm303zvv4ijzancrsb1cqbph3pgz0nky92k9qx3fq9y0vnchj"; }; </del> <ins> sha256 = "00zzm303zvv4ijzancrsb1cqbph3pgz0nky92k9qx3fq9y0vnchj"; </ins> })

<del> { stdenv, cmake, pkgconfig, libpng, libtiff, lcms2, glib/*passthru only*/ , sharedLibsSupport ? true # Build shared libraries , codecSupport ? true # Codec executables </del> <ins> { stdenv, fetchurl, cmake, pkgconfig , libpng, libtiff, lcms2 </ins> , mj2Support ? true # MJ2 executables , jpwlLibSupport ? true # JPWL library & executables <del> , jpipLibSupport ? true # JPIP library & executables </del> <ins> , jpipLibSupport ? false # JPIP library & executables </ins> , jpipServerSupport ? false, curl ? null, fcgi ? null # JPIP Server #, opjViewerSupport ? false, wxGTK ? null # OPJViewer executable <del> , openjpegJarSupport ? false, jdk ? null # Openjpeg jar (Java) </del> <ins> , openjpegJarSupport ? false # Openjpeg jar (Java) </ins> , jp3dSupport ? true # # JP3D comp , thirdPartySupport ? false # Third party libraries - OFF: only build when found, ON: always build , testsSupport ? false <ins> , jdk ? null </ins> # Inherit generics <del> , branch, src, version, ... </del> <ins> , branch, sha256, version, ... </ins> }: <del> assert jpipServerSupport -> (jpipLibSupport && (curl != null) && (fcgi != null)); </del> <ins> assert jpipServerSupport -> jpipLibSupport && curl != null && fcgi != null; </ins> #assert opjViewerSupport -> (wxGTK != null); <del> assert openjpegJarSupport -> (jdk != null); assert testsSupport -> codecSupport; </del> <ins> assert (openjpegJarSupport || jpipLibSupport) -> jdk != null; </ins> let <del> mkFlag = optSet: flag: if optSet then "-D${flag}=ON" else "-D${flag}=OFF"; </del> <ins> inherit (stdenv.lib) optional optionals; mkFlag = optSet: flag: "-D${flag}=${if optSet then "ON" else "OFF"}"; </ins> in <del> with stdenv.lib; </del> stdenv.mkDerivation rec { name = "openjpeg-${version}"; <del> inherit branch; inherit version; inherit src; </del> <ins> src = fetchurl { url = "mirror://sourceforge/openjpeg.mirror/${version}/openjpeg-${version}.tar.gz"; inherit sha256; }; </ins> cmakeFlags = [ <del> (mkFlag sharedLibsSupport "BUILD_SHARED_LIBS") (mkFlag codecSupport "BUILD_CODEC") </del> <ins> "-DCMAKE_INSTALL_NAME_DIR=${CMAKE_INSTALL_PREFIX}/lib" "-DBUILD_SHARED_LIBS=ON" "-DBUILD_CODEC=ON" </ins> (mkFlag mj2Support "BUILD_MJ2") (mkFlag jpwlLibSupport "BUILD_JPWL") (mkFlag jpipLibSupport "BUILD_JPIP") (mkFlag jpipServerSupport "BUILD_JPIP_SERVER") #(mkFlag opjViewerSupport "BUILD_VIEWER") <ins> "-DBUILD_VIEWER=OFF" </ins> (mkFlag openjpegJarSupport "BUILD_JAVA") (mkFlag jp3dSupport "BUILD_JP3D") (mkFlag thirdPartySupport "BUILD_THIRDPARTY") (mkFlag testsSupport "BUILD_TESTING") <del> ] ++ stdenv.lib.optionals stdenv.isDarwin [ "-DCMAKE_INSTALL_NAME_DIR=${CMAKE_INSTALL_PREFIX}/lib" </del> ]; <del> nativebuildInputs = [ pkgconfig ]; </del> <ins> nativeBuildInputs = [ cmake pkgconfig ]; </ins> <del> buildInputs = [ cmake ] </del> <ins> buildInputs = [ ] </ins> ++ optionals jpipServerSupport [ curl fcgi ] #++ optional opjViewerSupport wxGTK <del> ++ optional openjpegJarSupport jdk; </del> <ins> ++ optional (openjpegJarSupport || jpipLibSupport) jdk; </ins> propagatedBuildInputs = [ libpng libtiff lcms2 ]; <del> postInstall = glib.flattenInclude + '' mkdir -p "$out/lib/pkgconfig" cat > "$out/lib/pkgconfig/libopenjp2.pc" <<EOF prefix=$out libdir=$out/lib includedir=$out/include Name: openjp2 Description: JPEG2000 library (Part 1 and 2) URL: http://www.openjpeg.org/ Version: ${version} Libs: -L$out/lib -lopenjp2 Cflags: -I$out/include EOF ''; </del> passthru = { incDir = "openjpeg-${branch}"; }; <del> meta = { </del> <ins> meta = with stdenv.lib; { </ins> description = "Open-source JPEG 2000 codec written in C language"; <del> homepage    = http://www.openjpeg.org/; license     = licenses.bsd2; maintainer  = with maintainers; [ codyopel ]; platforms   = platforms.all; </del> <ins> homepage = http://www.openjpeg.org/; license = licenses.bsd2; maintainer = with maintainers; [ codyopel ]; platforms = platforms.all; </ins> }; }

opal = callPackage ../development/libraries/opal {}; openjpeg_1 = callPackage ../development/libraries/openjpeg/1.x.nix { }; <del> openjpeg_2_0_1 = callPackage ../development/libraries/openjpeg/2.0.1.nix { }; </del> <ins> openjpeg_2_0 = callPackage ../development/libraries/openjpeg/2.0.nix { }; </ins> openjpeg_2_1 = callPackage ../development/libraries/openjpeg/2.1.nix { }; openjpeg = openjpeg_2_1;

maxlib = callPackage ../applications/audio/pd-plugins/maxlib { }; mupdf = callPackage ../applications/misc/mupdf { <del> openjpeg = openjpeg_2_0_1; </del> <ins> openjpeg = openjpeg_2_0; </ins> }; mypaint = callPackage ../applications/graphics/mypaint { };