Notes Setting Up on Syncthing in NixOS
Table of Contents
So I recently got around to trying out NixOS. Part of that experience was setting up Syncthing, which I’ve used on the past on my machines and mobile phone to sync files related to note-taking.1
1 I use Emacs’s org-agenda to manage todos, and I’ve set up Orgzly Revived for basic creation and editing of org todos on my phone.
The configuration
Below is the final NixOS configuration I have (with IDs elided for privacy) alongside commentary via comments:
|
|
It was pretty straightforward to figure out the general settings for Syncthing by referencing NixOS Search. The tricky part was the “devices” and “folders” section. What should I put there? Below are the important bits.
Devices
- “Devices” are Machines/devices you’d like Syncthing to be aware of.
- Each machine has an ID.
- Each machine can optionally have a “label” (probably a human-readable name, like “Home computer”).
Looking at the relevant portion of my configuration:
|
|
This tells Syncthing that I have two devices:
- One labeled “G14 2024 Arch” with an ID of
"OQHSZRL-L2TT7IC-7USSLNU-ST7JYML-FOO-BAR"
. - Another labeled “OnePlus 7 Pro” with an ID of
"OVGYOBT-JPFQJKE-6CKRY7J-JULRCWK-FOO-BAR"
.
Now that Syncthing is aware of these devices, I can reference them by their label later in the folders section to specify which folders should be shared to which devices.
Folders
- Folders are the directories you’d like Syncthing to be aware of.
- Each folder has an ID.2
2 You can see the ID of shared folders in the Syncthing GUI by expanding the collapsed info section a folder under the folders section of the GUI’s homepage.
- Each folder may optionally have a label (probably a human-readable name, like “Agenda”). This is basically a nickname you give to the folder specific to the current device.
- Folders are only shared to devices specified for each folder.
Looking at the relevant portion of my configuration:
|
|
This tells Syncthing that I want to share two folders:
- Share folder
"k4vqh-foo"
, whose label is “Agenda,” with two devices: the one labeled “G14 2024 Arch WSL2” and another labeled “OnePlus 7 Pro.” - Share folder
"qtuzy-foo"
, whose label is “Notes,” with two devices: the one labeled “G14 2024 Arch WSL2” and another labeled “OnePlus 7 Pro.”
It is important that the “devices” section be specified, otherwise Syncthing will not sync those folders to other devices.
Closing remarks
And with that, I was done!
In sum:
- Devices
- “Devices” are Machines/devices you’d like Syncthing to be aware of.
- Each machine has an ID.
- Each machine can optionally have a “label” (probably a human-readable name, like “Home computer”).
- Folders
- Folders are the directories you’d like Syncthing to be aware of.
- Each folder has an ID.
- Each folder may optionally have a label (probably a human-readable name, like “Agenda”). This is basically a nickname you give to the folder specific to the current device.
- Folders are only shared to devices specified for each folder.
Simple, but it wasn’t obvious from the resources I encountered online, so I had to do some tinkering to figure it out myself.
For those who heavily customize Syncthing, there are other NixOS options available to tweak. You can find them in the NixOS Search for options. Additionally, if you are trying to migrate an existing Syncthing configuration to Nix, then you can check out your config file at ~/.config/syncthing/config.xml
. With this, you can see the value of every Syncthing setting (although the file will, of course, be in JSON format).
Other resources
- Syncthing - NixOS Wiki
- General resource; good starting point.
- Vimjoyer - YouTube
- A fantastic visual resource of making full use of Nix and NixOS. Has some beginner-friendly videos, but most videos are for intermediate or advanced users, ones looking to explore the ecosystem, full potential of Nix, and already having a familiarity with navigating Nix.