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


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
      onlyoffice = pkgs.fetchNextcloudApp {
        sha256 = "sha256-Z9QpvJiTpHqd8H4tEWKuoLs+i8JFYLEmj7Mk7E/2eJM=";
        url = "";
        license = "agpl3";
        appName = "OnlyOffice";
        appVersion = "9.0.0";
      memories = pkgs.fetchNextcloudApp {
        sha256 = "sha256-Xr1SRSmXo2r8yOGuoMyoXhD0oPVm/0/ISHlmNZpJYsg=";
        url = "";
        license = "agpl3";
      recognize = pkgs.fetchNextcloudApp {
        sha256 = "sha256-ziUc4J2y1lW1BwygwOKedOWbeAnPpBDwT9wh35R0MYk=";
        url = "";
        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.

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


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?


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 :/.