From 41fbd5568913fbbdc6e0b608d78bd14f0e4c1150 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Mon, 9 Sep 2019 12:07:46 +0200 Subject: [PATCH 1/8] zbar: format with nixpkgs-fmt --- pkgs/tools/graphics/zbar/default.nix | 60 +++++++++++++++++++++------- 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/pkgs/tools/graphics/zbar/default.nix b/pkgs/tools/graphics/zbar/default.nix index 503461018ab..bb1081074b9 100644 --- a/pkgs/tools/graphics/zbar/default.nix +++ b/pkgs/tools/graphics/zbar/default.nix @@ -1,12 +1,26 @@ -{ stdenv, fetchFromGitHub, imagemagickBig, pkgconfig, python2Packages, perl -, libX11, libv4l, qt5, gtk2, xmlto, docbook_xsl, autoreconfHook, dbus -, enableVideo ? stdenv.isLinux, enableDbus ? stdenv.isLinux +{ stdenv +, lib +, fetchFromGitHub +, imagemagickBig +, pkgconfig +, python2Packages +, perl +, libX11 +, libv4l +, qt5 +, gtk2 +, xmlto +, docbook_xsl +, autoreconfHook +, dbus +, enableVideo ? stdenv.isLinux +, enableDbus ? stdenv.isLinux }: -with stdenv.lib; let inherit (python2Packages) pygtk python; -in stdenv.mkDerivation rec { +in +stdenv.mkDerivation rec { pname = "zbar"; version = "0.23"; @@ -17,27 +31,43 @@ in stdenv.mkDerivation rec { sha256 = "0hlxakpyjg4q9hp7yp3har1n78341b4knwyll28hn48vykg28pza"; }; - nativeBuildInputs = [ pkgconfig xmlto autoreconfHook docbook_xsl ]; + nativeBuildInputs = [ + pkgconfig + xmlto + autoreconfHook + docbook_xsl + ]; buildInputs = [ - imagemagickBig python pygtk perl libX11 - ] ++ optional enableDbus dbus - ++ optionals enableVideo [ - libv4l gtk2 qt5.qtbase qt5.qtx11extras + imagemagickBig + python + pygtk + perl + libX11 + ] ++ lib.optionals enableDbus [ + dbus + ] ++ lib.optionals enableVideo [ + libv4l + gtk2 + qt5.qtbase + qt5.qtx11extras ]; configureFlags = (if enableDbus then [ - "--with-dbusconfdir=$out/etc/dbus-1/system.d" - ] else [ "--without-dbus" ]) - ++ optionals (!enableVideo) [ - "--disable-video" "--without-gtk" "--without-qt" + "--with-dbusconfdir=${placeholder "out"}/etc/dbus-1/system.d" + ] else [ + "--without-dbus" + ]) ++ lib.optionals (!enableVideo) [ + "--disable-video" + "--without-gtk" + "--without-qt" ]; postInstall = optionalString enableDbus '' install -Dm644 dbus/org.linuxtv.Zbar.conf $out/etc/dbus-1/system.d/org.linuxtv.Zbar.conf ''; - meta = with stdenv.lib; { + meta = with lib; { description = "Bar code reader"; longDescription = '' ZBar is an open source software suite for reading bar codes from various From e1cb839d17d7ec6bdf97624e0f1c0f0af6fb62c3 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 23 Jun 2019 13:39:01 +0200 Subject: [PATCH 2/8] zbar: Split to multiple outputs Also fix D-Bus config dir path: The configure script is appending `/dbus-1/system.d` so when we added passed in `$out/etc/dbus-1/system.d`, it ended up with extra nesting. --- pkgs/applications/misc/electrum/default.nix | 2 +- pkgs/tools/graphics/zbar/default.nix | 11 +++++++---- .../security/asc-key-to-qr-code-gif/default.nix | 15 ++++++++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/pkgs/applications/misc/electrum/default.nix b/pkgs/applications/misc/electrum/default.nix index c48d458567d..0ebeb1beffa 100644 --- a/pkgs/applications/misc/electrum/default.nix +++ b/pkgs/applications/misc/electrum/default.nix @@ -88,7 +88,7 @@ python3Packages.buildPythonApplication { --replace ${libsecp256k1_name} ${secp256k1}/lib/libsecp256k1${stdenv.hostPlatform.extensions.sharedLibrary} '' + (if enableQt then '' substituteInPlace ./electrum/qrscanner.py \ - --replace ${libzbar_name} ${zbar}/lib/libzbar${stdenv.hostPlatform.extensions.sharedLibrary} + --replace ${libzbar_name} ${zbar.lib}/lib/libzbar${stdenv.hostPlatform.extensions.sharedLibrary} '' else '' sed -i '/qdarkstyle/d' contrib/requirements/requirements.txt ''); diff --git a/pkgs/tools/graphics/zbar/default.nix b/pkgs/tools/graphics/zbar/default.nix index bb1081074b9..116f32a701b 100644 --- a/pkgs/tools/graphics/zbar/default.nix +++ b/pkgs/tools/graphics/zbar/default.nix @@ -24,6 +24,8 @@ stdenv.mkDerivation rec { pname = "zbar"; version = "0.23"; + outputs = [ "out" "py" "lib" "dev" "doc" "man" ]; + src = fetchFromGitHub { owner = "mchehab"; repo = "zbar"; @@ -54,7 +56,7 @@ stdenv.mkDerivation rec { ]; configureFlags = (if enableDbus then [ - "--with-dbusconfdir=${placeholder "out"}/etc/dbus-1/system.d" + "--with-dbusconfdir=${placeholder "out"}/etc" ] else [ "--without-dbus" ]) ++ lib.optionals (!enableVideo) [ @@ -63,9 +65,10 @@ stdenv.mkDerivation rec { "--without-qt" ]; - postInstall = optionalString enableDbus '' - install -Dm644 dbus/org.linuxtv.Zbar.conf $out/etc/dbus-1/system.d/org.linuxtv.Zbar.conf - ''; + makeFlags = [ + "pyexecdir=${placeholder "py"}/${python.sitePackages}" + "pythondir=${placeholder "py"}/${python.sitePackages}" + ]; meta = with lib; { description = "Bar code reader"; diff --git a/pkgs/tools/security/asc-key-to-qr-code-gif/default.nix b/pkgs/tools/security/asc-key-to-qr-code-gif/default.nix index 6b3a922bbe5..580cf7585c9 100644 --- a/pkgs/tools/security/asc-key-to-qr-code-gif/default.nix +++ b/pkgs/tools/security/asc-key-to-qr-code-gif/default.nix @@ -15,15 +15,20 @@ stdenv.mkDerivation { sha256 = "0yrc302a2fhbzryb10718ky4fymfcps3lk67ivis1qab5kbp6z8r"; }; - buildInputs = [ imagemagick qrencode ] ++ stdenv.lib.optional testQR zbar; dontBuild = true; dontStrip = true; dontPatchELF = true; - preInstall = '' - substituteInPlace asc-to-gif.sh \ - --replace "convert" "${imagemagick}/bin/convert" \ - --replace "qrencode" "${qrencode.bin}/bin/qrencode" + preInstall = let + substitutions = [ + ''--replace "convert" "${imagemagick}/bin/convert"'' + ''--replace "qrencode" "${qrencode.bin}/bin/qrencode"'' + ] ++ stdenv.lib.optional testQR [ + ''--replace "hash zbarimg" "true"'' # hash does not work on NixOS + ''--replace "$(zbarimg --raw" "$(${zbar.out}/bin/zbarimg --raw"'' + ]; + in '' + substituteInPlace asc-to-gif.sh ${stdenv.lib.concatStringsSep " " substitutions} ''; installPhase = '' From e1d57791548dc5330d20420ffa57461f1a612ed8 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 23 Jun 2019 15:06:01 +0200 Subject: [PATCH 3/8] v4l-utils: split to multiple outputs That required setting localedir to fix cycle. Also do not patch shebangs globally. --- pkgs/os-specific/linux/v4l-utils/default.nix | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pkgs/os-specific/linux/v4l-utils/default.nix b/pkgs/os-specific/linux/v4l-utils/default.nix index a688f60492a..73db222d390 100644 --- a/pkgs/os-specific/linux/v4l-utils/default.nix +++ b/pkgs/os-specific/linux/v4l-utils/default.nix @@ -19,14 +19,14 @@ in stdenv.mkDerivation rec { sha256 = "1ng0x3wj3a1ckfd00yxa4za43xms92gdp7rdag060b7p39z7m4gf"; }; - outputs = [ "out" "dev" ]; + outputs = [ "out" ] ++ lib.optional withUtils "lib" ++ [ "dev" ]; - configureFlags = - if withUtils then [ - "--with-udevdir=${placeholder "out"}/lib/udev" - ] else [ - "--disable-v4l-utils" - ]; + configureFlags = (if withUtils then [ + "--with-localedir=${placeholder "lib"}/share/locale" + "--with-udevdir=${placeholder "out"}/lib/udev" + ] else [ + "--disable-v4l-utils" + ]); postFixup = '' # Create symlink for V4l1 compatibility @@ -39,10 +39,8 @@ in stdenv.mkDerivation rec { propagatedBuildInputs = [ libjpeg ]; - NIX_CFLAGS_COMPILE = lib.optional withQt "-std=c++11"; - postPatch = '' - patchShebangs . + patchShebangs utils/cec-ctl/msg2ctl.pl ''; meta = with stdenv.lib; { From da135c2704e405e7e576a4e394027043d9781529 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 10 Sep 2019 00:35:05 +0200 Subject: [PATCH 4/8] zbar: drop pygtk support It is deprecated and we do not actually use it anywhere --- pkgs/tools/graphics/zbar/default.nix | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/pkgs/tools/graphics/zbar/default.nix b/pkgs/tools/graphics/zbar/default.nix index 116f32a701b..74503862785 100644 --- a/pkgs/tools/graphics/zbar/default.nix +++ b/pkgs/tools/graphics/zbar/default.nix @@ -3,7 +3,6 @@ , fetchFromGitHub , imagemagickBig , pkgconfig -, python2Packages , perl , libX11 , libv4l @@ -17,14 +16,11 @@ , enableDbus ? stdenv.isLinux }: -let - inherit (python2Packages) pygtk python; -in stdenv.mkDerivation rec { pname = "zbar"; version = "0.23"; - outputs = [ "out" "py" "lib" "dev" "doc" "man" ]; + outputs = [ "out" "lib" "dev" "doc" "man" ]; src = fetchFromGitHub { owner = "mchehab"; @@ -42,8 +38,6 @@ stdenv.mkDerivation rec { buildInputs = [ imagemagickBig - python - pygtk perl libX11 ] ++ lib.optionals enableDbus [ @@ -55,7 +49,9 @@ stdenv.mkDerivation rec { qt5.qtx11extras ]; - configureFlags = (if enableDbus then [ + configureFlags = [ + "--without-python" + ] ++ (if enableDbus then [ "--with-dbusconfdir=${placeholder "out"}/etc" ] else [ "--without-dbus" @@ -65,11 +61,6 @@ stdenv.mkDerivation rec { "--without-qt" ]; - makeFlags = [ - "pyexecdir=${placeholder "py"}/${python.sitePackages}" - "pythondir=${placeholder "py"}/${python.sitePackages}" - ]; - meta = with lib; { description = "Bar code reader"; longDescription = '' From 61fdd203d6e4e7e9c4b4b4ba0bfe0036666bc0d1 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 10 Sep 2019 00:55:11 +0200 Subject: [PATCH 5/8] zbar: wrap Qt frontend --- pkgs/tools/graphics/zbar/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/tools/graphics/zbar/default.nix b/pkgs/tools/graphics/zbar/default.nix index 74503862785..3574e2697c6 100644 --- a/pkgs/tools/graphics/zbar/default.nix +++ b/pkgs/tools/graphics/zbar/default.nix @@ -34,6 +34,7 @@ stdenv.mkDerivation rec { xmlto autoreconfHook docbook_xsl + qt5.wrapQtAppsHook ]; buildInputs = [ @@ -61,6 +62,12 @@ stdenv.mkDerivation rec { "--without-qt" ]; + dontWrapQtApps = true; + + postFixup = lib.optionalString enableVideo '' + wrapQtApp "$out/bin/zbarcam-qt" + ''; + meta = with lib; { description = "Bar code reader"; longDescription = '' From 021faed5bae0fc63990167174c619580bec59950 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 10 Sep 2019 01:05:55 +0200 Subject: [PATCH 6/8] zbar: switch to GTK 3 --- pkgs/tools/graphics/zbar/default.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkgs/tools/graphics/zbar/default.nix b/pkgs/tools/graphics/zbar/default.nix index 3574e2697c6..c3a1d63f911 100644 --- a/pkgs/tools/graphics/zbar/default.nix +++ b/pkgs/tools/graphics/zbar/default.nix @@ -7,7 +7,7 @@ , libX11 , libv4l , qt5 -, gtk2 +, gtk3 , xmlto , docbook_xsl , autoreconfHook @@ -45,7 +45,7 @@ stdenv.mkDerivation rec { dbus ] ++ lib.optionals enableVideo [ libv4l - gtk2 + gtk3 qt5.qtbase qt5.qtx11extras ]; @@ -56,15 +56,19 @@ stdenv.mkDerivation rec { "--with-dbusconfdir=${placeholder "out"}/etc" ] else [ "--without-dbus" - ]) ++ lib.optionals (!enableVideo) [ + ]) ++ (if enableVideo then [ + "--with-gtk=gtk3" + ] else [ "--disable-video" "--without-gtk" "--without-qt" - ]; + ]); dontWrapQtApps = true; + dontWrapGApps = true; postFixup = lib.optionalString enableVideo '' + wrapProgram "$out/bin/zbarcam-gtk" "''${gappsWrapperArgs[@]}" wrapQtApp "$out/bin/zbarcam-qt" ''; From 86f3b3f6282723065f15b8f7642fdcb6d6224db7 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 10 Sep 2019 01:06:47 +0200 Subject: [PATCH 7/8] zbar: drop Perl dependency It does not appear to be necessary --- pkgs/tools/graphics/zbar/default.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/tools/graphics/zbar/default.nix b/pkgs/tools/graphics/zbar/default.nix index c3a1d63f911..69737461929 100644 --- a/pkgs/tools/graphics/zbar/default.nix +++ b/pkgs/tools/graphics/zbar/default.nix @@ -3,7 +3,6 @@ , fetchFromGitHub , imagemagickBig , pkgconfig -, perl , libX11 , libv4l , qt5 @@ -39,7 +38,6 @@ stdenv.mkDerivation rec { buildInputs = [ imagemagickBig - perl libX11 ] ++ lib.optionals enableDbus [ dbus From 2eb7541b1acfad498b3367e2ecc0ebb4c5233b12 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 10 Sep 2019 05:54:35 +0200 Subject: [PATCH 8/8] zbar: use libsForQt5.callPackage --- pkgs/tools/graphics/zbar/default.nix | 10 ++++++---- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/tools/graphics/zbar/default.nix b/pkgs/tools/graphics/zbar/default.nix index 69737461929..cb5ea25211c 100644 --- a/pkgs/tools/graphics/zbar/default.nix +++ b/pkgs/tools/graphics/zbar/default.nix @@ -5,7 +5,9 @@ , pkgconfig , libX11 , libv4l -, qt5 +, qtbase +, qtx11extras +, wrapQtAppsHook , gtk3 , xmlto , docbook_xsl @@ -33,7 +35,7 @@ stdenv.mkDerivation rec { xmlto autoreconfHook docbook_xsl - qt5.wrapQtAppsHook + wrapQtAppsHook ]; buildInputs = [ @@ -44,8 +46,8 @@ stdenv.mkDerivation rec { ] ++ lib.optionals enableVideo [ libv4l gtk3 - qt5.qtbase - qt5.qtx11extras + qtbase + qtx11extras ]; configureFlags = [ diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ca37025f7f3..4272504037a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7182,7 +7182,7 @@ in zbackup = callPackage ../tools/backup/zbackup {}; - zbar = callPackage ../tools/graphics/zbar { }; + zbar = libsForQt5.callPackage ../tools/graphics/zbar { }; zdelta = callPackage ../tools/compression/zdelta { };