From 1da8ad17259f42d7b086fc8f2e26f6b02c6e3e28 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Tue, 19 Jul 2022 13:04:19 +0800 Subject: [PATCH 1/2] maintainers: add foo-dogsquared --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 68496e0d54c2..338a68a2fc5c 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -4356,6 +4356,12 @@ githubId = 405105; name = "Dustin Frisch"; }; + foo-dogsquared = { + email = "foo.dogsquared@gmail.com"; + github = "foo-dogsquared"; + githubId = 34962634; + name = "Gabriel Arazas"; + }; forkk = { email = "forkk@forkk.net"; github = "Forkk"; From 75c934681c7bcf3975f7d0200bd953554d3c6bf7 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Tue, 19 Jul 2022 13:06:10 +0800 Subject: [PATCH 2/2] gnome-frog: init at 1.1.3 --- pkgs/applications/misc/gnome-frog/default.nix | 89 +++++++++++++++++++ ...date-compatible-with-non-flatpak-env.patch | 33 +++++++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 124 insertions(+) create mode 100644 pkgs/applications/misc/gnome-frog/default.nix create mode 100644 pkgs/applications/misc/gnome-frog/update-compatible-with-non-flatpak-env.patch diff --git a/pkgs/applications/misc/gnome-frog/default.nix b/pkgs/applications/misc/gnome-frog/default.nix new file mode 100644 index 000000000000..0d8a658f3ea9 --- /dev/null +++ b/pkgs/applications/misc/gnome-frog/default.nix @@ -0,0 +1,89 @@ +{ stdenv +, lib +, fetchFromGitHub +, python3Packages +, wrapGAppsHook4 +, gtk4 +, meson +, ninja +, pkg-config +, appstream-glib +, desktop-file-utils +, glib +, gobject-introspection +, libnotify +, libadwaita +, libportal +, gettext +, librsvg +, tesseract5 +, zbar +}: + +python3Packages.buildPythonApplication rec { + pname = "gnome-frog"; + version = "1.1.3"; + + src = fetchFromGitHub { + owner = "TenderOwl"; + repo = "Frog"; + rev = version; + sha256 = "sha256-yOjfiGJUU25zb/4WprPU59yDAMpttS3jREp1kB5mXUE="; + }; + + format = "other"; + + patches = [ ./update-compatible-with-non-flatpak-env.patch ]; + postPatch = '' + chmod +x ./build-aux/meson/postinstall.py + patchShebangs ./build-aux/meson/postinstall.py + substituteInPlace ./build-aux/meson/postinstall.py \ + --replace "gtk-update-icon-cache" "gtk4-update-icon-cache" + substituteInPlace ./frog/language_manager.py --subst-var out + ''; + + nativeBuildInputs = [ + appstream-glib + desktop-file-utils + gettext + meson + ninja + pkg-config + glib + wrapGAppsHook4 + ]; + + buildInputs = [ + librsvg + gobject-introspection + libnotify + libadwaita + libportal + zbar + tesseract5 + ]; + + propagatedBuildInputs = with python3Packages; [ + pygobject3 + pillow + pytesseract + pyzbar + ]; + + # This is to prevent double-wrapping the package. We'll let + # Python do it by adding certain arguments inside of the + # wrapper instead. + dontWrapGApps = true; + preFixup = '' + makeWrapperArgs+=("''${gappsWrapperArgs[@]}") + ''; + + meta = with lib; { + homepage = "https://getfrog.app/"; + description = + "Intuitive text extraction tool (OCR) for GNOME desktop"; + license = licenses.mit; + maintainers = with maintainers; [ foo-dogsquared ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/applications/misc/gnome-frog/update-compatible-with-non-flatpak-env.patch b/pkgs/applications/misc/gnome-frog/update-compatible-with-non-flatpak-env.patch new file mode 100644 index 000000000000..aac9b4f76fd2 --- /dev/null +++ b/pkgs/applications/misc/gnome-frog/update-compatible-with-non-flatpak-env.patch @@ -0,0 +1,33 @@ +diff --git a/frog/config.py b/frog/config.py +index 9837755..b73e4e3 100644 +--- a/frog/config.py ++++ b/frog/config.py +@@ -30,10 +30,14 @@ import os + APP_ID = "com.github.tenderowl.frog" + RESOURCE_PREFIX = "/com/github/tenderowl/frog" + ++# This is based from the XDG Base Directory specification. ++if not os.getenv('XDG_DATA_HOME'): ++ os.environ['XDG_DATA_HOME'] = os.path.expanduser("~/.local/share") ++ + if not os.path.exists(os.path.join(os.environ['XDG_DATA_HOME'], 'tessdata')): + os.mkdir(os.path.join(os.environ['XDG_DATA_HOME'], 'tessdata')) + + tessdata_url = "https://github.com/tesseract-ocr/tessdata/raw/main/" + tessdata_best_url = "https://github.com/tesseract-ocr/tessdata_best/raw/main/" + tessdata_dir = os.path.join(os.environ['XDG_DATA_HOME'], 'tessdata') +-tessdata_config = f'--tessdata-dir {tessdata_dir} –psm 6' ++tessdata_config = f'–-psm 6 --tessdata-dir {tessdata_dir}' +diff --git a/frog/language_manager.py b/frog/language_manager.py +index 5752be6..4f6a908 100644 +--- a/frog/language_manager.py ++++ b/frog/language_manager.py +@@ -156,7 +156,7 @@ class LanguageManager(GObject.GObject): + os.mkdir(tessdata_dir) + + dest_path = os.path.join(tessdata_dir, 'eng.traineddata') +- source_path = pathlib.Path('/app/share/appdata/eng.traineddata') ++ source_path = pathlib.Path('@out@/share/appdata/eng.traineddata') + if os.path.exists(dest_path): + return + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6c8af61fe2f2..4540bffc7383 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6694,6 +6694,8 @@ with pkgs; gnome-feeds = callPackage ../applications/networking/feedreaders/gnome-feeds {}; + gnome-frog = callPackage ../applications/misc/gnome-frog { }; + gnome-keysign = callPackage ../tools/security/gnome-keysign { }; gnome-secrets = callPackage ../applications/misc/gnome-secrets { };