KDE Plasma 6.7, Spectacle OCR issue, package overlay: avoid compiling on every rebuild

Spectacle in KDE Plasma has 2 “hidden” features

  • it can extract text from images if tesseract is installed, language packs are installed and the languages are detected by the application
  • it can scan QR and Barcodes (somehow) if the package kdePackages.prison is installed

For OCR, there is a long existing issue

Spectacle does not detect the languagepacks of nixpkgs tesseract, an override can fix this

nixpkgs.overlays = [
    (final: prev: {
        kdePackages = prev.kdePackages.overrideScope (
            kdeFinal: kdePrev: {
                spectacle = kdePrev.spectacle.override {
                    # language shortcodes: https://github.com/tesseract-ocr/tessdoc/blob/f0e2e52803c3ebf281bee2fda8a6d2e168dff266/Data-Files-in-different-versions.md
                    tesseractLanguages = [
                        "eng"           # english
                        "deu"           # german
                        "rus"           # russian
                        "ukr"           # ukrainian
                        "chi_sim"       # chinese simplified
                        "chi_tra"       # chinese traditional
                        "ara"           # arabic
                    ];
                };
            }
        );
    })
];

now this causes Spectacle to be recompiled on every nixos-rebuild, apparently even if there is no change?

Is there a simple way to cache that override somehow to avoid rebuilding it every time? On a weak system this causes big problems and makes quick system changes basically impossible.

1 Like

btw, on that topic. There are no tesseract languagepacks and it seems they are ALL installed.

tesseract --list-langs
List of available languages in "/nix/store/2mbp5bfl1xzj9qp9j9vkga0wg5nzv46n-tesseract-5.5.2/share/tessdata/" (129):
...

what about changing the default spectacle package to configure all these languages? Would this cause more languages to be pulled in?

though it seems this specific problem might be fixed soon and I just need to wait for it to arrive in unstable, it would still be useful to know

  • how to avoid recompilations every time
  • if tesseracts includes all languages and if this would cause higher resource use etc.

How often do you update your channels or flake inputs? Could you build spectacle on another machine and cache to Cachix?

I update my channels on every update, to update. But as nothing should change with spectacle, why wouldnt it use the cache?

But it seems like it does not recompile every time anymore, might have been a coincidental package update directly after.