From d69583c6c26551d30e7dac024fb83a65e13e1f65 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 27 Sep 2021 13:57:14 +0000 Subject: [PATCH] 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. --- .../manual/from_md/release-notes/rl-2111.section.xml | 10 ++++++++++ nixos/doc/manual/release-notes/rl-2111.section.md | 2 ++ pkgs/development/libraries/opencv/default.nix | 5 +++-- pkgs/tools/graphics/pfstools/default.nix | 7 ++++--- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml index b6e69da6d89c..0688de77af68 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml @@ -1059,6 +1059,16 @@ Superuser created successfully. changelog. + + + 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. + +
diff --git a/nixos/doc/manual/release-notes/rl-2111.section.md b/nixos/doc/manual/release-notes/rl-2111.section.md index ebc200c4ad52..56babf8ac006 100644 --- a/nixos/doc/manual/release-notes/rl-2111.section.md +++ b/nixos/doc/manual/release-notes/rl-2111.section.md @@ -331,6 +331,8 @@ In addition to numerous new and upgraded packages, this release has the followin respectively. As a result `services.datadog-agent` has had breaking changes to the configuration file. For details, see the [upstream changelog](https://github.com/DataDog/datadog-agent/blob/main/CHANGELOG.rst). +- `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. + ## Other Notable Changes {#sec-release-21.11-notable-changes} diff --git a/pkgs/development/libraries/opencv/default.nix b/pkgs/development/libraries/opencv/default.nix index 005257780e40..ed2f700dc82e 100644 --- a/pkgs/development/libraries/opencv/default.nix +++ b/pkgs/development/libraries/opencv/default.nix @@ -9,6 +9,7 @@ , enableFfmpeg ? false, ffmpeg , enableGStreamer ? false, gst_all_1 , enableEigen ? true, eigen +, enableUnfree ? false , Cocoa, QTKit }: @@ -67,7 +68,7 @@ stdenv.mkDerivation rec { (opencvFlag "PNG" enablePNG) (opencvFlag "OPENEXR" enableEXR) (opencvFlag "GSTREAMER" enableGStreamer) - ]; + ] ++ lib.optional (!enableUnfree) "-DBUILD_opencv_nonfree=OFF"; hardeningDisable = [ "bindnow" "relro" ]; @@ -82,7 +83,7 @@ stdenv.mkDerivation rec { meta = with lib; { description = "Open Computer Vision Library with more than 500 algorithms"; homepage = "https://opencv.org/"; - license = licenses.bsd3; + license = if enableUnfree then licenses.unfree else licenses.bsd3; maintainers = with maintainers; [ ]; platforms = platforms.linux; }; diff --git a/pkgs/tools/graphics/pfstools/default.nix b/pkgs/tools/graphics/pfstools/default.nix index 99b9e3e0e487..a81321204757 100644 --- a/pkgs/tools/graphics/pfstools/default.nix +++ b/pkgs/tools/graphics/pfstools/default.nix @@ -1,6 +1,7 @@ { lib, stdenv, mkDerivation, fetchurl, cmake, pkg-config, darwin , openexr, zlib, imagemagick6, libGLU, libGL, freeglut, fftwFloat -, fftw, gsl, libexif, perl, opencv2, qtbase, netpbm +, fftw, gsl, libexif, perl, qtbase, netpbm +, enableUnfree ? false, opencv2 }: mkDerivation rec { @@ -28,12 +29,12 @@ mkDerivation rec { nativeBuildInputs = [ cmake pkg-config ]; buildInputs = [ openexr zlib imagemagick6 fftwFloat - fftw gsl libexif perl opencv2 qtbase netpbm + fftw gsl libexif perl qtbase netpbm ] ++ (if stdenv.isDarwin then (with darwin.apple_sdk.frameworks; [ OpenGL GLUT ]) else [ libGLU libGL freeglut - ]); + ]) ++ lib.optional enableUnfree (opencv2.override { enableUnfree = true; }); patches = [ ./threads.patch ./pfstools.patch ./pfsalign.patch ];