Cannot change home dir / datadir in nextcloud

I have installed and tested nextcloud previously, with default services.nextcloud.home, so It created /var/lib/nextcloud directory for nextcloud. And it works fine.
However My SSD drive is soo small, so that I would like to set the storage to another hard disk, say /mnt/HD1.
I renamed /var/lib/nextcloud to other name for backup purpuse.
When I set services.nextcloud.home to /mnt/HD1 and run nixos-rebuild switch, it shows the error message: nextcloud-setup-start: The username is already being used.
I tried commented out nextcloud related configs, run nixos-rebuild switch, uncommend those, then run nixos-rebuild swich again, same error message popped up.
Seems some of the config were already store in /nix/store and reused, I think thats the problem.
I don’t care about any existing nextcloud config and data in the directory. I just want to change the storage path to my hard disk. What should I do now?
Also may I ask what is the difference between services.nextcloud.home and services.nextcloud.datadir actually? Which one should I use if my only concern is just the disk size?
Thanks for your help!

Due to systemd hardening and sandboxing, I think it will be easier to just mount your disk at /var/lib/nextcloud.

1 Like

Nice suggestion! Thanks!

Hi! I’m in the same situation but i want the datadir on a network share. I got permissions error. The nextcloud module cannot create folder or cannot chown. I tried with nfs and cifs and also in the /var/lib folder. Any idea how i must mount the share so that the nextcloud module has the needed permissions?