Nextcloud with declarative apps (memories + recognize). Unable to download models for recognize app

Hello.

I have nextcloud installed and I have apps like:

    extraApps = with inputs.nixpkgs.outputs.legacyPackages.x86_64-linux.nextcloud28.packages.apps; {
      inherit contacts calendar tasks notes previewgenerator notify_push twofactor_nextcloud_notification twofacto
r_webauthn;
      onlyoffice = pkgs.fetchNextcloudApp {
        sha256 = "sha256-Z9QpvJiTpHqd8H4tEWKuoLs+i8JFYLEmj7Mk7E/2eJM=";
        url = "https://github.com/ONLYOFFICE/onlyoffice-nextcloud/releases/download/v9.0.0/onlyoffice.tar.gz";
        license = "agpl3";
        appName = "OnlyOffice";
        appVersion = "9.0.0";
      };
      memories = pkgs.fetchNextcloudApp {
        sha256 = "sha256-Xr1SRSmXo2r8yOGuoMyoXhD0oPVm/0/ISHlmNZpJYsg=";
        url = "https://github.com/pulsejet/memories/releases/download/v6.2.2/memories.tar.gz";
        license = "agpl3";
      };
      recognize = pkgs.fetchNextcloudApp {
        sha256 = "sha256-ziUc4J2y1lW1BwygwOKedOWbeAnPpBDwT9wh35R0MYk=";
        url = "https://github.com/nextcloud/recognize/releases/download/v6.1.1/recognize-6.1.1.tar.gz";
        license = "agpl3";
        appName = "recognize";
        appVersion = "6.1.1";
      };
    };

and I would like to download models with:

# nextcloud-occ recognize:download-models
Failed to download models
Unable to open "/nix/store/82wpw01yl3nkacq6yxr0dh84q4jmajfc-nextcloud-app-recognize-6.1.1/lib/Service/../../models.tar.gz" using mode "w+": fopen(/nix/store/82wpw01yl3nkacq6yxr0dh84q4jmajfc-nextcloud-app-recognize-6.1.1/lib/Service/../../models.tar.gz): Failed to open stream: Read-only file system

but it ends with errors, because nix store is read only.

Do anyone able to help? I would like to download models directly while nix-rebuild.
Recognize app is not much nixos friendly.

There is another solution:
recompile recognize app via Nix and add post install scripts, but it seems to be complicated at first look.

1 Like

Iā€™m looking into this as well.

Not great at NixOS stuff yet but other apps can use the data folder I think.

The alternative is to use an OCI container for recognize for now until we can solve a more nixy solution

1 Like

Hello.

People usually enable app store and then doing backup of nextcloud directory.
But Iā€™m really looking for true nix way ;).

hard solution:

  • recompile application and download models after compilation via build hooks

soft sloution:

  • figure out how to wrap? fetchNextcloudApp and download models during deploy

And it looks like there is another ā€œhackā€ which can be used:

Based on:

extraApps = {
      calendar = pkgs.stdenvNoCC.mkDerivation rec {
        name = "calendar";
        src = /home/onny/projects/calendar;
        unpackPhase = ''cp -r --no-preserve=mode $src/* .'';
        dontBuild = true;
        installPhase = ''cp -r --no-preserve=mode . $out/'';
      };
      mail = pkgs.nextcloud25Packages.apps.mail;
    };

It seems like way how to do it :).

1 Like

@marmolak i have same problem not sure if i understand how you fixed it, can you share with us the code?

Hello.

I still havenā€™t had the time to fully solve this. However, Iā€™m attempting to gather as many possible ways to reach one place and then explore them.

if helps I think the problem is this occ download model call here recognize/lib/Service/DownloadModelsService.php at c012fcc2aa57cb3e074764ba8038f70042c17683 Ā· nextcloud/recognize Ā· GitHub

and is expecting to save the file in the same path where the .php files exists so not possible. we could try to patch this file using nix patches so is saving the file somewhere else or we could just understand what this code does to download and register the model and simulate same thing in a nix derivation.

1 Like

Iā€™m also trying to use my nextcloud on NixOS with recognize. For me it also shows the error Could not execute the Node.js binary. You may need to set the path to a working binary manually. in the admin panel. How did you guys solve this?

And also, how did any of you solve the model downloading?

Hi. Still no progress from my side :/.

You can fix that error by addng:

services.nextcloud.extraOptions.recognize.node_binary = "${lib.getExe pkgs.nodejs_22}";

Hello.

Do I need something else to configure? This doesnā€™t work for me and I still have issues with downloading models.

What do you mean by ā€œit doesnā€™t work for meā€? Iā€™d need more context to help you.

The model downloading still doesnā€™t work and the download path is hardcoded, unfortunately. Iā€™m not deep enough in the whole topic (and want to switch to immich anyway) to solve that.

But the recognition works on my machine, even without the model, for some reason.

Unfortunately this does not seem to work for me :thinking: I still see errors in my nextcloud log:

Error	core	
ErrorException Classifier process error
Error while running background job OCA\Recognize\BackgroundJobs\ClassifyFacesJob (id: 20587, arguments: {"storageId":4,"rootId":40}) 

and also

Warning	recognize	
Classifier process output: /run/current-system/sw/bin/nice: ā€˜ā€™: No such file or directory 

Also I was wondering how do you know of this config setting? I canā€™t seem to find any documentation or even any mentioning of this setting.

So, the error of the not found node binary is gone now, right?

I had the same issue and I think I reverse-engineered the config value by setting a weird value in the admin setting in the browser and then 'grepā€™ing that weird value to find out the config key to set. Itā€™s been a month, though. So I donā€™t recall the exact way I found out how to tell recognize the node binary.

I donā€™t know about your errors, though and currently canā€™t check. All I know is that it kinda worked, even though it couldnā€™t download the models. I stopped dhecking the logs after that.

Hi Guys,
Iā€™m facing the same problem :confused:

I will try the soft solution approach this evening if I find some time and post the results in case Iā€™m successful

No, sorry, it still canā€™t find the nodejs binary :thinking: