config/users/pbsds/syncthing.nix

69 lines
2.8 KiB
Nix
Raw Permalink Normal View History

2024-09-21 21:30:46 +02:00
{ config, lib, pkgs, ...}:
2024-09-27 17:04:03 +02:00
# todo: portable service and system-manager
2024-09-21 21:30:46 +02:00
{
environment.systemPackages = lib.mkIf config.services.syncthing.enable [
(pkgs.makeDesktopItem {
desktopName = "Open Syncthing";
name = "Syncthing";
2024-10-10 21:24:11 +02:00
exec = "${pkgs.xdg-utils}/bin/xdg-open http://${config.services.syncthing.guiAddress}";
2024-09-21 21:30:46 +02:00
icon = "${pkgs.syncthing.src}/assets/logo-512.png";
})
];
services.syncthing = {
enable = true;
user = lib.mkDefault "pbsds";
group = lib.mkDefault "pbsds";
2024-09-27 11:13:26 +02:00
dataDir = lib.mkDefault (config.users.users.pbsds.home + "/syncthing");
2024-09-21 21:30:46 +02:00
overrideDevices = true; # overrides devices from WebUI
overrideFolders = true; # overrides folders from WebUI
settings = {
2024-09-22 02:51:30 +02:00
options.urAccepted = -1; # disable telemetry
2024-09-22 02:14:49 +02:00
2024-09-21 21:30:46 +02:00
# TODO: nox
2024-10-12 20:31:24 +02:00
# TODO: eple
2024-09-21 21:30:46 +02:00
# TODO: somehow disable gui
# TODO: somehow auto-make a gui user+password
# TODO: somehow don't create ~/Sync
2024-10-12 20:31:24 +02:00
# TODO: sync documents folder
# TODO: move state folder
2024-09-21 21:30:46 +02:00
2024-09-29 16:11:07 +02:00
# webui http://localhost:8384/
2024-09-21 21:30:46 +02:00
# nix run -- nixpkgs#syncthing generate --config="$HOME"/syncthing/.config/syncthing
2024-09-27 18:07:05 +02:00
devices."bjarte".id = "C7QQYJU-PMJDP2Z-CKTAV4A-V6IFEG5-YFBGCNU-PJPCZFC-QSXKZY3-NC5WRAL";
devices."pjudduzen".id = "JCNX5AC-YMXJZBP-5LQRLAL-BGTSXKK-X6AJPXL-IXDWJGW-IHSBTPT-AFXKFAK";
devices."rocm".id = "UFW6V4E-LMEDTYR-23BU6BP-2HEMWYB-2ARCJ4X-T67WHZX-BNCCHZ4-5GPSZQV";
devices."sopp".id = "ZQJEWAX-GALDJDO-FBOE5ON-M5XKXNT-PRZD3CY-S7L3XDR-PR27NYL-RZ6O7QW";
2024-09-29 16:00:04 +02:00
devices."nord".id = "C6N5NVA-AXCQ23G-4D4U3A6-WLNXCRC-PBE3PLB-P4SATUU-PSB2MN2-WOZPHAL";
2024-09-27 18:14:59 +02:00
/* devices."bjarte".autoAcceptFolders = true; # TODO */
2024-09-21 21:30:46 +02:00
2024-09-27 18:07:05 +02:00
folders = lib.flip lib.pipe [
2024-10-10 21:24:11 +02:00
# add `path` default
2024-09-27 18:07:05 +02:00
(lib.mapAttrs (name: attrs: { path = lib.mkDefault "${config.services.syncthing.dataDir}/${name}"; } // attrs ))
2024-10-10 21:24:11 +02:00
# filter folders this host does not have access to
2024-09-27 18:07:05 +02:00
(lib.mapAttrsToList (name: attrs: lib.mkIf (builtins.elem config.networking.hostName (attrs.devices or [])) { ${name} = attrs; } ))
lib.mkMerge
] {
/* "ntnu".ignorePerms = false; # `false` means sync file permissions */
2024-10-12 20:31:24 +02:00
"DCIM".devices = [ "pjudduzen" "bjarte" "sopp" ];
2024-09-27 18:07:05 +02:00
"ntnu".devices = [ "bjarte" "sopp" "rocm" ];
2024-10-08 15:17:22 +02:00
"mihon".devices = [ "pjudduzen" "bjarte" "nord" ];
2024-09-29 16:11:07 +02:00
"ewesticker".devices = [ "pjudduzen" "bjarte" "sopp" "rocm" "nord" ];
2024-09-27 18:07:05 +02:00
"pjudduzen-clover".devices = [ "pjudduzen" "sopp" ];
"pjudduzen-movies".devices = [ "pjudduzen" "sopp" ];
"pjudduzen-music".devices = [ "pjudduzen" "sopp" ];
2024-09-27 18:14:59 +02:00
"pjudduzen-pictures".devices = [ "pjudduzen" "sopp" "bjarte" ];
2024-09-27 18:07:05 +02:00
"pjudduzen-snapchat".devices = [ "pjudduzen" "sopp" ];
2024-09-27 18:14:59 +02:00
/* "foobar".type = "receiveencrypted"; */
2024-09-21 21:30:46 +02:00
};
};
};
}