opencv2: don't build unfree libraries by default

In opencv 2.x, unfree libraries are built by default. The package
should therefore have been marked as unfree, but wasn't.

I've disabled the non-free libraries by default, and added an option
to enable them. There are three programs in Nixpkgs that depend on
opencv2: mathematica, pfstools, and p2pvc. pfstools requires the
non-free libraries if it's built with opencv support, so I've disabled
opencv by default there and added an option to enable it. p2pvc links
fine, so presumably doesn't need the non-free libraries. I can't test
mathematica, so I'm just going to leave it alone.

+19 -5
+10
nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
··· 1059 changelog</link>. 1060 </para> 1061 </listitem> 1062 </itemizedlist> 1063 </section> 1064 <section xml:id="sec-release-21.11-notable-changes">
··· 1059 changelog</link>. 1060 </para> 1061 </listitem> 1062 + <listitem> 1063 + <para> 1064 + <literal>opencv2</literal> no longer includes the non-free 1065 + libraries by default, and consequently 1066 + <literal>pfstools</literal> no longer includes OpenCV support 1067 + by default. Both packages now support an 1068 + <literal>enableUnfree</literal> option to re-enable this 1069 + functionality. 1070 + </para> 1071 + </listitem> 1072 </itemizedlist> 1073 </section> 1074 <section xml:id="sec-release-21.11-notable-changes">
+2
nixos/doc/manual/release-notes/rl-2111.section.md
··· 331 respectively. As a result `services.datadog-agent` has had breaking changes to the 332 configuration file. For details, see the [upstream changelog](https://github.com/DataDog/datadog-agent/blob/main/CHANGELOG.rst). 333 334 ## Other Notable Changes {#sec-release-21.11-notable-changes} 335 336
··· 331 respectively. As a result `services.datadog-agent` has had breaking changes to the 332 configuration file. For details, see the [upstream changelog](https://github.com/DataDog/datadog-agent/blob/main/CHANGELOG.rst). 333 334 + - `opencv2` no longer includes the non-free libraries by default, and consequently `pfstools` no longer includes OpenCV support by default. Both packages now support an `enableUnfree` option to re-enable this functionality. 335 + 336 ## Other Notable Changes {#sec-release-21.11-notable-changes} 337 338
+3 -2
pkgs/development/libraries/opencv/default.nix
··· 9 , enableFfmpeg ? false, ffmpeg 10 , enableGStreamer ? false, gst_all_1 11 , enableEigen ? true, eigen 12 , Cocoa, QTKit 13 }: 14 ··· 67 (opencvFlag "PNG" enablePNG) 68 (opencvFlag "OPENEXR" enableEXR) 69 (opencvFlag "GSTREAMER" enableGStreamer) 70 - ]; 71 72 hardeningDisable = [ "bindnow" "relro" ]; 73 ··· 82 meta = with lib; { 83 description = "Open Computer Vision Library with more than 500 algorithms"; 84 homepage = "https://opencv.org/"; 85 - license = licenses.bsd3; 86 maintainers = with maintainers; [ ]; 87 platforms = platforms.linux; 88 };
··· 9 , enableFfmpeg ? false, ffmpeg 10 , enableGStreamer ? false, gst_all_1 11 , enableEigen ? true, eigen 12 + , enableUnfree ? false 13 , Cocoa, QTKit 14 }: 15 ··· 68 (opencvFlag "PNG" enablePNG) 69 (opencvFlag "OPENEXR" enableEXR) 70 (opencvFlag "GSTREAMER" enableGStreamer) 71 + ] ++ lib.optional (!enableUnfree) "-DBUILD_opencv_nonfree=OFF"; 72 73 hardeningDisable = [ "bindnow" "relro" ]; 74 ··· 83 meta = with lib; { 84 description = "Open Computer Vision Library with more than 500 algorithms"; 85 homepage = "https://opencv.org/"; 86 + license = if enableUnfree then licenses.unfree else licenses.bsd3; 87 maintainers = with maintainers; [ ]; 88 platforms = platforms.linux; 89 };
+4 -3
pkgs/tools/graphics/pfstools/default.nix
··· 1 { lib, stdenv, mkDerivation, fetchurl, cmake, pkg-config, darwin 2 , openexr, zlib, imagemagick6, libGLU, libGL, freeglut, fftwFloat 3 - , fftw, gsl, libexif, perl, opencv2, qtbase, netpbm 4 }: 5 6 mkDerivation rec { ··· 28 nativeBuildInputs = [ cmake pkg-config ]; 29 buildInputs = [ 30 openexr zlib imagemagick6 fftwFloat 31 - fftw gsl libexif perl opencv2 qtbase netpbm 32 ] ++ (if stdenv.isDarwin then (with darwin.apple_sdk.frameworks; [ 33 OpenGL GLUT 34 ]) else [ 35 libGLU libGL freeglut 36 - ]); 37 38 patches = [ ./threads.patch ./pfstools.patch ./pfsalign.patch ]; 39
··· 1 { lib, stdenv, mkDerivation, fetchurl, cmake, pkg-config, darwin 2 , openexr, zlib, imagemagick6, libGLU, libGL, freeglut, fftwFloat 3 + , fftw, gsl, libexif, perl, qtbase, netpbm 4 + , enableUnfree ? false, opencv2 5 }: 6 7 mkDerivation rec { ··· 29 nativeBuildInputs = [ cmake pkg-config ]; 30 buildInputs = [ 31 openexr zlib imagemagick6 fftwFloat 32 + fftw gsl libexif perl qtbase netpbm 33 ] ++ (if stdenv.isDarwin then (with darwin.apple_sdk.frameworks; [ 34 OpenGL GLUT 35 ]) else [ 36 libGLU libGL freeglut 37 + ]) ++ lib.optional enableUnfree (opencv2.override { enableUnfree = true; }); 38 39 patches = [ ./threads.patch ./pfstools.patch ./pfsalign.patch ]; 40