Syncthing config not recreated in home folder

I’ve spent the last few days learning NixOS and putting a config together for a couple of development machines I have. These are single user (me, although it appears I’m running NixOS multi-user) machines and I’m just trying to learn the core of Nix for now so I’m not using Flakes or Home Manager.

I’m trying to treat my users home dir as ephemeral, to ensure I have everything (except secrets) in the configuration. I set up a lovely syncthing config and it worked fine until I did eventually nuke it. However, it’s not being recreated. I’d configured the syncthing user as me (phil) and the configDir as /home/phil/.config/syncthing which I think is the default anyway but I was using the default syncthing user until I noticed all the permissions were wrong and switched. dataDir is set to /data (my user owns this folder).

I guess I could completely remove the user (and /home dir) but I would like to understand what’s going on before I do that.

I suspect it’s a lack of understanding of what conditions under which this config is created. I checked the syncthing.nix source code but couldn’t spot anything obvious.

Where I can I’ve been creating config under /etc and where an app doesn’t check that as default symlinking it to my homedir using extraInit. Not sure if that’s right, I need to re-read the architecture stuff to wrap my head around it all but I’m getting there.

I should probably also mention that I’m trying to use the declarative style user config which looks like this:

users.extraUsers.USER_NAME = {
  isNormalUser = true;
  createHome = true;
  uid = 1000;
  description = "USER_FULLNAME";
  hashedPassword = "USER_PASSWORD";
  extraGroups = [ "wheel" "docker" "networkmanager" "video" ];
users.mutableUsers = false;

I substitute the uppercase variables before building with sudo nixos-rebuild. I can probably just move this to a non-versioned .nix file but I’m still playing around with the config.

What is your ephemeral home setup? Checkout GitHub - nix-community/impermanence: Modules to help you handle persistent state on systems with ephemeral root storage [maintainer=@talyz] for creating symlinks from a persistent store.

What do the syncthing logs say?

I run syncthing as the system user and have shares in my home directory: Running Syncthing as a System User on NixOS

1 Like

Thank you for your reply! Setting up as a system user could be ideal. I’ll follow that post. Thanks.

My home isn’t really ephemeral but I want to treat it as such so I can keep my preferences synced between machines and also when I add new machines or upgrade which happens a fair bit as I like to toy. Perhaps it’d just be better to use Syncthing to sync the home dir too but that seems kinda unstable if there are differences that get wiped out and not very Nix.

I’ve not checked the Syncthing logs but the config.xml is not getting recreated and the pem files aren’t being copied. Basically, ~/.config/syncthing is empty (but it wasn’t the first time I did a rebuild). I assumed this meant it’s a problem with the Nix install rather than Syncthing’s problem.

Presumbly your config ends up in the syncthing user’s home dir, right?

Thanks again, certainly some stuff to try/learn.

Hi @nitinpassa,
I tried the system config in your blog post but it’s still not getting recreated. I guess there is some deeper problem. Fortunately, I can just wipe it and start again as I’ve have most of the configuration setup correctly.

After looking into your suggestion about using impermanence I found this article about why you’d want to do this and this is exactly what I want. So I’m going have a crack at setting that up and hopefully fix my issue in the process.

1 Like

It’s hard to say what’s going on without looking at the logs and your configuration. It’s possible syncthing isn’t starting at all. Maybe the directory is being created and then mounted over with another.

I also leave my syncthing config directory under /var/lib/syncthing since it’s running as a system service.

1 Like

Thank you!

I eventually heeded your words and checked journalctl. Turns out I’d specified the path to the pem files incorrectly. I’d used plain strings. I could have sworn I’d set that up already but I must have set it before copying out the pem files (lots of late nights!).

It’s a bit confusing (for a noob) as the Syncthing paths that are required are actually strings not paths. So to ensure NixOS can source them they need to be pulled in as paths then interpolated so they are the correct type (string).

syncthing.key = "${../secrets/darko/syncthing.key.pem}";
syncthing.cert = "${../secrets/darko/syncthing.cert.pem}";