From 7998307f772c1b7c6e1e97e1ba20f759dee17d77 Mon Sep 17 00:00:00 2001 From: Kate Adkins Date: Tue, 12 Nov 2024 16:41:38 -0700 Subject: [PATCH] linux: add syncthing --- flake.nix | 1 + nixos/configs/syncthing.nix | 54 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 nixos/configs/syncthing.nix diff --git a/flake.nix b/flake.nix index 33355ba..4785f07 100644 --- a/flake.nix +++ b/flake.nix @@ -209,6 +209,7 @@ ./nixos/configs/nix.nix ./nixos/configs/dotfiles ./nixos/configs/calendar.nix + ./nixos/configs/syncthing.nix ./nixos/configs/include-conf.nix ./nixos/configs/flake-registry.nix ./nixos/configs/storage-optimization.nix diff --git a/nixos/configs/syncthing.nix b/nixos/configs/syncthing.nix new file mode 100644 index 0000000..ac00cf1 --- /dev/null +++ b/nixos/configs/syncthing.nix @@ -0,0 +1,54 @@ +# +# All-device synchronization via Syncthing. +# +{ config, is-droid, ... }: +let + # The list of devices and their IDs. + devices = { + "valere" = { id = "VLZYF6C-OHG66RM-O72IMW3-S35YWAV-TYFJJVU-KAMJR7G-2XRLCVB-XOY6IAG"; }; + "design" = { id = "XLTC5OX-3ZU6CYZ-MJ7TAY7-ZAMRIE4-SS2JWFB-FC3RJIO-B3BIQFV-J7U53QK"; }; + }; + + # + +in +{ + services.syncthing = { + enable = !is-droid; + openDefaultPorts = true; + + # Run as our user, and adopt our permissions. + user = "deprekated"; + + # Primary configuration. + settings = { + + # Set up the webUI, accessible only via localhost. + gui = { + enabled = true; + address = "tcp://127.0.0.1:8384"; + }; + + }; + + # Set up the devices that we allow to connect. + # See the big table above. + inherit devices; + + # Set op our main sync'd folder. + folders."synced" = { + path = "/home/deprekated/synced"; + devices = builtins.attrNames devices; + + # Treat this like a sync'd folder that we always have acess to. + ignorePerms = true; + }; + }; + + + # Extra config passed through the environment. + systemd.services.syncthing.environment = { + STNODEFAULTFOLDER = "true"; + }; + +}