Hello, I recently migrated the data folder and database of an existing Nextcloud (Ubuntu snap solution) instance into a NixOS Nextcloud instance.
When testing I discovered that I get permission errors when accessing files in shared folders.
The relevant configuration:
{
lib,
pkgs,
...
}:
{
# Nextcloud settings.
services.nextcloud.enable = true;
services.nextcloud.hostName = "localhost";
services.nextcloud.config.dbtype = "mysql";
services.nextcloud.config.dbname = "nextcloud"; # Using the default.
services.nextcloud.package = pkgs.nextcloud34;
services.nextcloud.maxUploadSize = "512M"; # Using the default.
services.nextcloud.database.createLocally = true;
systemd.services."phpfpm-nextcloud".serviceConfig.ReadWritePaths = [
"/var/lib/nextcloud/data"
];
# Nextcloud credentials.
services.nextcloud.config.adminuser = "admin";
# Initial admin password, used only at install time.
services.nextcloud.config.adminpassFile = builtins.toFile "initial-nextcloud-admin-password" ''
NextCloudInitialPwd
'';
# Nextcloud apps.
services.nextcloud.extraApps = {
# Present in nixpkgs.
inherit (pkgs.nextcloud34Packages.apps)
calendar
collectives
contacts
files_automatedtagging
groupfolders
guests
notes
spreed;
# Not present in nixpkgs.
richdocumentscode = pkgs.fetchNextcloudApp {
url = "https://github.com/CollaboraOnline/richdocumentscode/releases/download/26.4.104/richdocumentscode.tar.gz";
hash = "sha256-0EYu1q03/A2jPYkSemslcW1Lp9EaNBqPrCgYCbOeLs0=";
license = lib.licenses.asl20.shortName;
};
};
# PHP Runtime.
services.nextcloud.phpPackage = pkgs.php84;
# Open nextcloud ports in the firewall.
networking.firewall.allowedTCPPorts = [
80 # HTTP.
];
# NEXTCLOUD.
# Trusted nextcloud domains.
services.nextcloud.settings.trusted_domains = [
"192.168.0.136"
"mydomain.com"
];
# Extra nextcloud config. Inherited from the snap instance.
services.nextcloud.settings = {
"debug" = true;
"instanceid" = "old_instance_id";
"defaultapp" = "files";
"secret" = "old_secret";
"passwordsalt" = "old_password_salt";
};
users.groups.nextcloud = {
gid = 992;
};
users.users.nextcloud = {
uid = 994;
group = "nextcloud";
};
# EXTERNAL MOUNTS.
fileSystems."/var/lib/nextcloud/data" = {
device = "nextcloud@192.168.0.148:/mnt/BigDump/nextcloud/data";
fsType = "sshfs";
options = [
"nodev" # Do not treat as unix device.
"noatime" # Do not register access time to win performance.
"allow_other" # Allow other ussers to access the mount.
"reconnect" # Reconnect after failure.
"ServerAliveInterval=30" # Keep the connection alive by sending a keepalive packet every x seconds.
"IdentityFile=/root/.ssh/id_ed25519" # Local SSH client key for login.
"idmap=user" # Map remote user with local user uid and gid.
"uid=${toString config.users.users.nextcloud.uid}" # User id for the mounted file system.
"gid=${toString config.users.groups.nextcloud.gid}" # Group id for the mounted file system.
];
};
}
Symptoms when accessing a shared file:
journalctl -xeu phpfpm-nextcloud.service
aug 25 13:57:36 nixtcloud Nextcloud[946]: {"reqId":"ox1bPqqQof7CPFIVU12W","level":3,"time":"2026-08-25T11:57:36+00:00","remoteAddr":"192.168.0.215","user":"dse","app":"text","method":"PUT","url":"/apps/text/session/141709/create","scriptName":"/index.php","message":"{\"Exception\":\"OCP\\\\Files\\\\NotFoundException\",\"Message\":\"\",\"Code\":0,\"Trace\":[{\"file\":\"/nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/apps/text/lib/Service/ApiService.php\",\"line\":66,\"function\":\"getFileById\",\"class\":\"OCA\\\\Text\\\\Service\\\\DocumentService\",\"type\":\"->\"},{\"file\":\"/nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/apps/text/lib/Controller/SessionController.php\",\"line\":46,\"function\":\"create\",\"class\":\"OCA\\\\Text\\\\Service\\\\ApiService\",\"type\":\"->\",\"args\":[\"*** sensitive parameters replaced ***\"]},{\"file\":\"/nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":165,\"function\":\"create\",\"class\":\"OCA\\\\Text\\\\Controller\\\\SessionController\",\"type\":\"->\",\"args\":[\"*** sensitive parameters replaced ***\"]},{\"file\":\"/nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":78,\"function\":\"executeController\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\"},{\"file\":\"/nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/lib/private/AppFramework/App.php\",\"line\":137,\"function\":\"dispatch\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\"},{\"file\":\"/nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/lib/private/Route/Router.php\",\"line\":324,\"function\":\"main\",\"class\":\"OC\\\\AppFramework\\\\App\",\"type\":\"::\"},{\"file\":\"/nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/lib/base.php\",\"line\":1172,\"function\":\"match\",\"class\":\"OC\\\\Route\\\\Router\",\"type\":\"->\"},{\"file\":\"/nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/index.php\",\"line\":25,\"function\":\"handleRequest\",\"class\":\"OC\",\"type\":\"::\"}],\"File\":\"/nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/apps/text/lib/Service/DocumentService.php\",\"Line\":557,\"message\":\"No permission to access this file\",\"exception\":\"{\\\"class\\\":\\\"OCP\\\\Files\\\\NotFoundException\\\",\\\"message\\\":\\\"\\\",\\\"code\\\":0,\\\"file\\\":\\\"/nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/apps/text/lib/Service/DocumentService.php:557\\\",\\\"trace\\\":\\\"#0 /nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/apps/text/lib/Service/ApiService.php(66): OCA\\\\Text\\\\Service\\\\DocumentService->getFileById()\\\\n#1 /nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/apps/text/lib/Controller/SessionController.php(46): OCA\\\\Text\\\\Service\\\\ApiService->create()\\\\n#2 /nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/lib/private/AppFramework/Http/Dispatcher.php(165): OCA\\\\Text\\\\Controller\\\\SessionController->create()\\\\n#3 /nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/lib/private/AppFramework/Http/Dispatcher.php(78): OC\\\\AppFramework\\\\Http\\\\Dispatcher->executeController()\\\\n#4 /nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/lib/private/AppFramework/App.php(137): OC\\\\AppFramework\\\\Http\\\\Dispatcher->dispatch()\\\\n#5 /nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/lib/private/Route/Router.php(324): OC\\\\AppFramework\\\\App::main()\\\\n#6 /nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/lib/base.php(1172): OC\\\\Route\\\\Router->match()\\\\n#7 /nix/store/1p22hhkvnsj697vj0ipzn1igim9hfw6w-nextcloud-34.0.3/index.php(25): OC::handleRequest()\\\\n#8 {main}\\\"}\",\"CustomMessage\":\"No permission to access this file\"}","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:154.0) Gecko/20100101 Firefox/154.0","version":"34.0.3.2"}
I have checked filesystem permissions and there is no difference between files in my user folder where I do have access and my shared folder where I don’t have access.
Any hints to what I should check would be very helpful, thanks.