From 8647d1d515a57877140bff6f1609cb50b48e94b7 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Wed, 30 Nov 2022 13:02:57 +0000 Subject: [PATCH 1/3] python3.pkgs.zxing_cpp: init at 1.4.0 --- .../libraries/zxing-cpp/default.nix | 5 ++ .../python-modules/zxing_cpp/default.nix | 49 +++++++++++++++++++ .../zxing_cpp/use-nixpkgs-pybind11.patch | 14 ++++++ pkgs/top-level/python-packages.nix | 2 + 4 files changed, 70 insertions(+) create mode 100644 pkgs/development/python-modules/zxing_cpp/default.nix create mode 100644 pkgs/development/python-modules/zxing_cpp/use-nixpkgs-pybind11.patch diff --git a/pkgs/development/libraries/zxing-cpp/default.nix b/pkgs/development/libraries/zxing-cpp/default.nix index b9d61e5af626..bcddfa96552f 100644 --- a/pkgs/development/libraries/zxing-cpp/default.nix +++ b/pkgs/development/libraries/zxing-cpp/default.nix @@ -3,6 +3,7 @@ , fetchFromGitHub , pkg-config , cmake +, python3 }: stdenv.mkDerivation rec { @@ -37,6 +38,10 @@ stdenv.mkDerivation rec { --replace '$'{prefix}/@CMAKE_INSTALL_INCLUDEDIR@ @CMAKE_INSTALL_FULL_INCLUDEDIR@ ''; + passthru.tests = { + inherit (python3.pkgs) zxing_cpp; + }; + meta = with lib; { homepage = "https://github.com/nu-book/zxing-cpp"; description = "C++ port of zxing (a Java barcode image processing library)"; diff --git a/pkgs/development/python-modules/zxing_cpp/default.nix b/pkgs/development/python-modules/zxing_cpp/default.nix new file mode 100644 index 000000000000..9f58b7014ae2 --- /dev/null +++ b/pkgs/development/python-modules/zxing_cpp/default.nix @@ -0,0 +1,49 @@ +{ buildPythonPackage +, lib +, cmake +, pybind11 +, zxing-cpp +, numpy +, pillow +}: + +buildPythonPackage rec { + pname = "zxing_cpp"; + inherit (zxing-cpp) src version; + + sourceRoot = "source/wrappers/python"; + patches = [ + ./use-nixpkgs-pybind11.patch + ]; + dontUseCmakeConfigure = true; + + propagatedBuildInputs = [ + pybind11 + numpy + ]; + + nativeBuildInputs = [ + cmake + ]; + + checkInputs = [ + pillow + ]; + + meta = with lib; { + homepage = "https://github.com/zxing-cpp/zxing-cpp"; + description = "Python bindings for C++ port of zxing (a Java barcode image processing library)"; + longDescription = '' + ZXing-C++ ("zebra crossing") is an open-source, multi-format 1D/2D barcode + image processing library implemented in C++. + + It was originally ported from the Java ZXing Library but has been + developed further and now includes many improvements in terms of quality + and performance. It can both read and write barcodes in a number of + formats. + ''; + license = licenses.asl20; + maintainers = with maintainers; [ lukegb ]; + platforms = with platforms; unix; + }; +} diff --git a/pkgs/development/python-modules/zxing_cpp/use-nixpkgs-pybind11.patch b/pkgs/development/python-modules/zxing_cpp/use-nixpkgs-pybind11.patch new file mode 100644 index 000000000000..4a4960f13d6d --- /dev/null +++ b/pkgs/development/python-modules/zxing_cpp/use-nixpkgs-pybind11.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index eadfc045..b6f273a6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -20,8 +20,7 @@ if (NOT hasParent) + # In development mode, when the whole zxing-cpp directory is checked out, build against head code. + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../core ZXing EXCLUDE_FROM_ALL) + +- include(${CMAKE_CURRENT_SOURCE_DIR}/../../zxing.cmake) +- zxing_add_package(pybind11 pybind11 ${pybind11_git_repo} ${pybind11_git_rev}) ++ find_package(pybind11 CONFIG) + else() + # we don't have access to the top-level cmake helpers -> simply fetch it unconditional + include(FetchContent) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 5c357d23bfc9..ce103e4e3119 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -12396,4 +12396,6 @@ self: super: with self; { zwave-js-server-python = callPackage ../development/python-modules/zwave-js-server-python { }; zxcvbn = callPackage ../development/python-modules/zxcvbn { }; + + zxing_cpp = callPackage ../development/python-modules/zxing_cpp { }; } From 8a4ef886530590f5a705b78e9635fdcfde313d12 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Wed, 30 Nov 2022 13:04:33 +0000 Subject: [PATCH 2/3] mkFlutterApp: support apps which don't produce a .packages --- pkgs/build-support/flutter/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 691b2c5c6e60..68a6675cf543 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -88,7 +88,8 @@ let # so we can use lock, diff yaml cp "pubspec.yaml" "$RES" cp "pubspec.lock" "$RES" - mv .dart_tool .flutter-plugins .flutter-plugins-dependencies .packages "$RES/f" + [[ -e .packages ]] && mv .packages "$RES/f" + mv .dart_tool .flutter-plugins .flutter-plugins-dependencies "$RES/f" # replace paths with placeholders find "$RES" -type f -exec sed -i \ @@ -119,7 +120,7 @@ let find "$RES/.pub-cache" -iname "*.json" -exec sed -r 's|.*_fetchedAt.*| "_fetchedAt": "'"$DART_DATE"'",|g' -i {} + replace_line_matching "$RES/f/.dart_tool/package_config.json" '"generated"' '"generated": "'"$DART_DATE"'",' replace_line_matching "$RES/f/.flutter-plugins-dependencies" '"date_created"' '"date_created": "'"$DART_DATE"'",' - remove_line_matching "$RES/f/.packages" "Generated by pub" + [[ -e "$RES/f/.packages" ]] && remove_line_matching "$RES/f/.packages" "Generated by pub" # nuke refs find "$RES" -type f -exec nuke-refs {} + From e4f139a78e9aab829bad5bddafa7ea6d55f6f1b4 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Wed, 30 Nov 2022 13:05:16 +0000 Subject: [PATCH 3/3] yubioath-flutter: init at 6.0.2 --- .../misc/yubioath-flutter/default.nix | 57 +++++++++++++++++++ .../misc/yubioath-flutter/helper.nix | 44 ++++++++++++++ pkgs/top-level/aliases.nix | 2 +- pkgs/top-level/all-packages.nix | 2 + 4 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 pkgs/applications/misc/yubioath-flutter/default.nix create mode 100644 pkgs/applications/misc/yubioath-flutter/helper.nix diff --git a/pkgs/applications/misc/yubioath-flutter/default.nix b/pkgs/applications/misc/yubioath-flutter/default.nix new file mode 100644 index 000000000000..d858605e9044 --- /dev/null +++ b/pkgs/applications/misc/yubioath-flutter/default.nix @@ -0,0 +1,57 @@ +{ lib +, flutter +, python3 +, fetchFromGitHub +, stdenv +, pcre2 +}: + +let + vendorHashes = { + x86_64-linux = "sha256-BwhWA8N0S55XkljDKPNkDhsj0QSpmJJ5MwEnrPjymS8="; + aarch64-linux = "sha256-T1aGz3+2Sls+rkUVDUo39Ky2igg+dxGSUaf3qpV7ovQ="; + }; + + version = "6.0.2"; + src = fetchFromGitHub { + owner = "Yubico"; + repo = "yubioath-flutter"; + rev = version; + sha256 = "13nh5qpq02c6azfdh4cbzhlrq0hs9is45q5z5cnxg84hrx26hd4k"; + }; + meta = with lib; { + description = "Yubico Authenticator for Desktop"; + homepage = "https://github.com/Yubico/yubioath-flutter"; + license = licenses.asl20; + maintainers = with maintainers; [ lukegb ]; + platforms = builtins.attrNames vendorHashes; + }; + + helper = python3.pkgs.callPackage ./helper.nix { inherit src version meta; }; +in +flutter.mkFlutterApp rec { + pname = "yubioath-flutter"; + inherit src version meta; + + passthru.helper = helper; + + vendorHash = vendorHashes."${stdenv.system}"; + + postPatch = '' + substituteInPlace linux/CMakeLists.txt \ + --replace "../build/linux/helper" "${helper}/libexec/helper" + ''; + + preInstall = '' + # Make sure we have permission to delete things CMake has copied in to our build directory from elsewhere. + chmod -R +w build/ + ''; + postInstall = '' + # Swap the authenticator-helper symlink with the correct symlink. + ln -fs "${helper}/bin/authenticator-helper" "$out/app/helper/authenticator-helper" + ''; + + buildInputs = [ + pcre2 + ]; +} diff --git a/pkgs/applications/misc/yubioath-flutter/helper.nix b/pkgs/applications/misc/yubioath-flutter/helper.nix new file mode 100644 index 000000000000..a37ae01990ab --- /dev/null +++ b/pkgs/applications/misc/yubioath-flutter/helper.nix @@ -0,0 +1,44 @@ +{ buildPythonApplication +, poetry-core +, yubikey-manager +, fido2 +, mss +, zxing_cpp +, pillow +, cryptography + +, src +, version +, meta +}: + +buildPythonApplication rec { + pname = "yubioath-flutter-helper"; + inherit src version meta; + + sourceRoot = "source/helper"; + format = "pyproject"; + + postPatch = '' + sed -i \ + -e 's,zxing-cpp = .*,zxing-cpp = "*",g' \ + -e 's,mss = .*,mss = "*",g' \ + pyproject.toml + ''; + + postInstall = '' + install -Dm 0755 authenticator-helper.py $out/bin/authenticator-helper + install -d $out/libexec/helper + ln -fs $out/bin/authenticator-helper $out/libexec/helper/authenticator-helper + ''; + + propagatedBuildInputs = [ + poetry-core + yubikey-manager + fido2 + mss + zxing_cpp + pillow + cryptography + ]; +} diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index a316b8ada750..515e6fce58fc 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -1638,7 +1638,7 @@ mapAliases ({ youtubeDL = throw "'youtubeDL' has been renamed to/replaced by 'youtube-dl'"; # Converted to throw 2022-02-22 ytop = throw "ytop has been abandoned by upstream. Consider switching to bottom instead"; yubikey-neo-manager = throw "yubikey-neo-manager has been removed because it was broken. Use yubikey-manager-qt instead"; # Added 2021-03-08 - yubioath-desktop = throw "yubioath-desktop has been deprecated by upstream in favor of https://github.com/Yubico/yubioath-flutter"; # Added 2022-11-22 + yubioath-desktop = throw "yubioath-desktop has been deprecated by upstream in favor of yubioath-flutter"; # Added 2022-11-22 yuzu-ea = yuzu-early-access; # Added 2022-08-18 yuzu = yuzu-mainline; # Added 2021-01-25 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4bae0a7823cb..d8ba7a5c8d7d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -23177,6 +23177,8 @@ with pkgs; yubihsm-shell = callPackage ../tools/security/yubihsm-shell { }; + yubioath-flutter = callPackage ../applications/misc/yubioath-flutter { }; + zchunk = callPackage ../development/libraries/zchunk { }; zeitgeist = callPackage ../development/libraries/zeitgeist { };