syncthing.nix
1 { 2 pkgs, 3 config, 4 lib, 5 #sops-nix, 6 ... 7 }: 8 #with lib; 9 let 10 cfg = config.modules.syncthing; 11 12 all_devices = [ 13 "immortal" 14 "stellar" 15 #"horizon" 16 "pixel8" 17 "pixel6" 18 ]; 19 in 20 { 21 options = { 22 modules.syncthing = { 23 enable = lib.mkEnableOption "service"; 24 }; 25 }; 26 config = lib.mkIf cfg.enable { 27 services.syncthing = { 28 #allProxy = "socks5://address.com:1234"; 29 cert = config.sops.secrets."syncthing/cert".path; 30 enable = true; 31 #extraOptions = [ "--test" ]; 32 #guiAddress = "127.0.0.1:8384"; 33 key = config.sops.secrets."syncthing/key".path; 34 overrideDevices = true; 35 overrideFolders = true; 36 passwordFile = config.sops.secrets."syncthing/password".path; 37 settings = { 38 devices = { 39 immortal = { 40 id = "HOYMAKE-ZN44TBY-LVD5YVO-ML57TIP-Z2HDDLO-BB5OSBM-XYD43WX-DOPPZAJ"; 41 }; 42 stellar = { 43 id = "CA3XBIH-S6U2TFK-LX5VJBS-SMZXGSI-2UM6PO2-AN4MM4J-2NLKLQL-UKEO7Q6"; 44 }; 45 /* 46 horizon = { 47 id = "test"; 48 }; 49 */ 50 pixel8 = { 51 id = "FR6RKN5-N7WNOUT-7G2HLO2-DXV27JC-7764HKZ-HTYXDXR-X5ACXVT-DAEC3Q6"; 52 }; 53 pixel6 = { 54 id = "6JHCNHN-KJ3AEVM-GH6GYAA-F3M4E4N-2GQL7X5-26L36YQ-6F5D52A-WCL3DA5"; 55 }; 56 57 }; 58 folders = { 59 "${config.xdg.userDirs.documents}" = { 60 id = "Documents"; 61 devices = [ 62 63 ] 64 ++ all_devices; 65 }; 66 "${config.xdg.userDirs.music}" = { 67 id = "Music"; 68 devices = [ 69 70 ] 71 ++ all_devices; 72 }; 73 "${config.xdg.userDirs.pictures}" = { 74 id = "Pictures"; 75 devices = [ 76 ] 77 ++ all_devices; 78 }; 79 "Sync" = { 80 id = "Sync"; 81 devices = [ 82 83 ] 84 ++ all_devices; 85 path = "${config.home.homeDirectory}/Sync"; 86 }; 87 88 ".Secret" = { 89 id = ".Secret"; 90 devices = [ 91 92 ] 93 ++ all_devices; 94 path = "${config.home.homeDirectory}/.Secret"; 95 }; 96 ".DecSync" = { 97 id = ".DecSync"; 98 devices = [ 99 100 ] 101 ++ all_devices; 102 path = "${config.home.homeDirectory}/.DecSync"; 103 }; 104 "DCIM" = { 105 id = "DCIM"; 106 devices = [ 107 "pixel8" 108 ]; 109 path = "${config.home.homeDirectory}/DCIM"; 110 }; 111 }; 112 options = { 113 #limitBandwidthInLan = null; 114 #localAnnounceEnabled = null; 115 #localAnnouncePort = null; 116 #maxFolderConcurrency = null; 117 relaysEnabled = true; 118 urAccepted = -1; 119 }; 120 }; 121 #tray.command = ""; 122 tray.enable = true; 123 tray.package = pkgs.syncthingtray-minimal; 124 }; 125 sops.secrets."syncthing/cert" = { }; 126 sops.secrets."syncthing/key" = { }; 127 sops.secrets."syncthing/password" = { 128 sopsFile = ./../../home-manager/secrets/common.yaml; 129 }; 130 }; 131 }