diff --git a/customPackages/default.nix b/customPackages/default.nix index a8197b0..094a305 100644 --- a/customPackages/default.nix +++ b/customPackages/default.nix @@ -1,16 +1,10 @@ { pkgs }: let - src_frog = ( pkgs.fetchFromGitHub { - owner = "sadan4"; - repo = "frog"; - rev = "2f2cc11ce7866e9b4bd0f6c52ba0cef25e95a468"; - hash = "sha256-KkoNi8Rx0Q6MIzgzvpCJhGI82tDWuflBQO2dFS0h8ig="; - }); in rec{ # discord = nixpkgs.callPackage ./discord { }; discord = pkgs.callPackage ./discord/default.nix { }; vesktop = pkgs.callPackage ./vesktop/default.nix { inherit vencord; }; vencord = pkgs.callPackage ./vencord/package.nix { }; - frog = pkgs.callPackage (import src_frog) {}; + frog = pkgs.callPackage ./frog {}; } diff --git a/customPackages/frog/default.nix b/customPackages/frog/default.nix new file mode 100644 index 0000000..fced2c1 --- /dev/null +++ b/customPackages/frog/default.nix @@ -0,0 +1,100 @@ +{ stdenv +, lib +, fetchFromGitHub +, python3Packages +, wrapGAppsHook4 +, gtk4 +, meson +, ninja +, pkg-config +, appstream-glib +, desktop-file-utils +, glib +, gobject-introspection +, blueprint-compiler +, libxml2 +, libnotify +, libadwaita +, libportal +, gettext +, librsvg +, tesseract5 +, zbar +, gst_all_1 +}: + +python3Packages.buildPythonApplication rec { + pname = "gnome-frog"; + version = "1.5.1"; + + src = ( fetchFromGitHub { + owner = "sadan4"; + repo = "frog"; + rev = "4e43c19701032de6dc741c92ed505f8fe660fbbb"; + hash = "sha256-olQofXrUF97NvY/lYBic/u50zuFvuOm4XrWUKn83xac="; + }); + 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 + gobject-introspection + blueprint-compiler + libxml2 + ]; + + buildInputs = [ + librsvg + libnotify + libadwaita + libportal + zbar + tesseract5 + gst_all_1.gstreamer + ]; + + propagatedBuildInputs = with python3Packages; [ + loguru + nanoid + posthog + pygobject3 + python-dateutil + pillow + pytesseract + pyzbar + gtts + ]; + + # 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; + mainProgram = "frog"; + maintainers = with maintainers; [ foo-dogsquared ]; + platforms = platforms.linux; + }; +} diff --git a/customPackages/frog/update-compatible-with-non-flatpak-env.patch b/customPackages/frog/update-compatible-with-non-flatpak-env.patch new file mode 100644 index 0000000..f122394 --- /dev/null +++ b/customPackages/frog/update-compatible-with-non-flatpak-env.patch @@ -0,0 +1,14 @@ +diff --git a/frog/language_manager.py b/frog/language_manager.py +index d822c44..bc289db 100644 +--- a/frog/language_manager.py ++++ b/frog/language_manager.py +@@ -193,7 +193,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 + +