Syncthing "permission denied"

Hello, I am having some issues with syncthing, here is my setup:
configuration.nix

services.syncthing = {
    enable = true;
    openDefaultPorts = true;
    settings.gui = {
      user = <my user>;
      password = "";
    };
    settings = {
      devices = {
        "phone" = { id = <phone id>; };
      };
      folders = {
        <name> = {
          id = <folder id>;
          path = <path to folder>;
          devices = [ "phone" ];
          ignorePerms = true;
        };
      };
    };
  };

nixos-rebuild switch works as expected

But when I open the web interface at http://127.0.0.1:8384/#, I get this error:

Failed to create folder root directory: stat <path to folder>: permission denied 

(And others in the same folder ending in permission denied)
I have the following permission on the folder:

drwxrwxr-x  2 syncthing syncthing 4096 <today> <folder name>

You’ll also note that although I wrote ignorePerms = true; in the advanced settings gui for that folder, “Ignore Permissions” is unchecked (checking it manually does not fix the problem)

I’m both a linux and NixOS begginner, but I’ve tried every fix I’ve come across, and it still doesn’t work, does anyone have any ideas ?

I had that too. I’m a NixOS begginner.
this works for me:

basic syncthing.nix

{ config, pkgs, ... }:

{
  services.syncthing = {
    enable = true;
    user = "myusername";
    dataDir = "/home/myusername";  # default location for new folders
    configDir = "/home/myusername/.config/syncthing";
  };
}

Added to imports in configuration.nix

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      ./syncthing.nix
    ];
1 Like

Thank you so much, that worked !

For future reference, here are my updated settings:

services.syncthing = {
    enable = true;
    openDefaultPorts = true;
    user = <my user>;
    configDir = "/home/<my user>/.conifg/syncthing";
    settings = {
      devices = {
        "phone" = { id = <phone id>; };
      };
      folders = {
        <name> = {
          id = <folder id>;
          path = <path to folder>;
          devices = [ "phone" ];
          ignorePerms = true;
        };
      };
    };
  };
1 Like