From a1d785c763ad9c954c67d94d07051a4247347e4a Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Fri, 27 Sep 2024 09:49:35 +0200 Subject: [PATCH 1/2] normcap: add desktop entry, drop patching --- pkgs/by-name/no/normcap/package.nix | 35 +++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/pkgs/by-name/no/normcap/package.nix b/pkgs/by-name/no/normcap/package.nix index a93db6de0279..bf34dba250cb 100644 --- a/pkgs/by-name/no/normcap/package.nix +++ b/pkgs/by-name/no/normcap/package.nix @@ -7,6 +7,8 @@ , wl-clipboard , libnotify , xorg +, makeDesktopItem +, copyDesktopItems }: let @@ -37,12 +39,6 @@ ps.buildPythonApplication rec { hash = "sha256-iMlW8oEt4OSipJaQ2XzBZeBVqiZP/C1sM0f5LYjv7/A="; }; - postPatch = '' - # disable coverage testing - substituteInPlace pyproject.toml \ - --replace-fail "addopts = [" "addopts_ = [" - ''; - pythonRemoveDeps = [ "pyside6-essentials" ]; @@ -51,11 +47,15 @@ ps.buildPythonApplication rec { "shiboken6" ]; - nativeBuildInputs = [ + build-system = [ ps.hatchling ps.babel ]; + nativeBuildInputs = [ + copyDesktopItems + ]; + dependencies = [ ps.pyside6 ps.jeepney @@ -69,8 +69,15 @@ ps.buildPythonApplication rec { ) ''; + postInstall = lib.optionalString stdenv.hostPlatform.isLinux '' + mkdir -p $out/share/pixmaps + ln -s $out/${python3.sitePackages}/normcap/resources/icons/normcap.png $out/share/pixmaps/ + ''; + nativeCheckInputs = wrapperDeps ++ [ ps.pytestCheckHook + ps.pytest-cov-stub + ps.pytest-instafail ps.pytest-qt ps.toml ] ++ lib.optionals stdenv.hostPlatform.isLinux [ @@ -136,6 +143,20 @@ ps.buildPythonApplication rec { "tests/tests_gui/test_loading_indicator.py" ]; + desktopItems = [ + (makeDesktopItem { + name = "com.github.dynobo.normcap"; + desktopName = "NormCap"; + genericName = "OCR powered screen-capture tool"; + comment = "Extract text from an image directly into clipboard"; + exec = "normcap"; + icon = "normcap"; + terminal = false; + categories = ["Utility" "Office"]; + keywords = ["Text" "Extraction" "OCR"]; + }) + ]; + meta = with lib; { description = "OCR powered screen-capture tool to capture information instead of images"; homepage = "https://dynobo.github.io/normcap/"; From c722b770fefa3edb0f1f7bc95b7a4e603e98fb99 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Fri, 27 Sep 2024 10:06:25 +0200 Subject: [PATCH 2/2] normcap: unbreak darwin --- pkgs/by-name/no/normcap/package.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/no/normcap/package.nix b/pkgs/by-name/no/normcap/package.nix index bf34dba250cb..8404231fa392 100644 --- a/pkgs/by-name/no/normcap/package.nix +++ b/pkgs/by-name/no/normcap/package.nix @@ -50,6 +50,8 @@ ps.buildPythonApplication rec { build-system = [ ps.hatchling ps.babel + ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ + ps.toml ]; nativeBuildInputs = [ @@ -114,10 +116,15 @@ ps.buildPythonApplication rec { # flaky "test_normcap_ocr_testcases" ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ + # requires display + "test_send_via_qt_tray" + "test_screens" # requires impure pbcopy "test_get_copy_func_with_pbcopy" "test_get_copy_func_without_pbcopy" "test_perform_pbcopy" + "test_pbcopy" + "test_copy" # NSXPCSharedListener endpointForReply:withListenerName:replyErrorCode: # while obtaining endpoint 'ClientCallsAuxiliary': Connection interrupted # since v5.0.0 @@ -139,8 +146,16 @@ ps.buildPythonApplication rec { # requires a display "tests/integration/test_normcap.py" "tests/integration/test_tray_menu.py" + "tests/integration/test_settings_menu.py" + "tests/tests_clipboard/test_handlers/test_qtclipboard.py" + "tests/tests_gui/test_tray.py" + "tests/tests_gui/test_window.py" + "tests/tests_screengrab/" # failure unknown, crashes in first test with `.show()` "tests/tests_gui/test_loading_indicator.py" + "tests/tests_gui/test_menu_button.py" + "tests/tests_gui/test_resources.py" + "tests/tests_gui/test_update_check.py" ]; desktopItems = [ @@ -163,6 +178,5 @@ ps.buildPythonApplication rec { license = licenses.gpl3Plus; maintainers = with maintainers; [ cafkafk pbsds ]; mainProgram = "normcap"; - broken = stdenv.hostPlatform.isDarwin; }; }