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