mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2025-12-06 09:07:21 +01:00
chore: centralize syncthing config
This commit is contained in:
parent
e107d0743b
commit
4323aed986
5 changed files with 200 additions and 356 deletions
|
|
@ -2665,12 +2665,10 @@ This machine mainly acts as an external sync helper. It manages the following th
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
#+begin_src nix-ts :tangle hosts/nixos/moonside/default.nix
|
#+begin_src nix-ts :tangle hosts/nixos/moonside/default.nix
|
||||||
{ lib, config, globals, ... }:
|
{ lib, config, ... }:
|
||||||
let
|
let
|
||||||
inherit (config.repo.secrets.common) workHostName;
|
|
||||||
inherit (config.repo.secrets.local.syncthing) dev1 dev2 dev3 loc1;
|
inherit (config.repo.secrets.local.syncthing) dev1 dev2 dev3 loc1;
|
||||||
inherit (config.swarselsystems) sopsFile;
|
inherit (config.swarselsystems) sopsFile;
|
||||||
serviceDomain = config.repo.secrets.common.services.domains.syncthing3;
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
|
@ -2693,15 +2691,6 @@ This machine mainly acts as an external sync helper. It manages the following th
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
etc."issue".text = "\4";
|
etc."issue".text = "\4";
|
||||||
|
|
||||||
persistence."/persist".directories = lib.mkIf config.swarselsystems.isImpermanence [
|
|
||||||
{
|
|
||||||
directory = "/var/lib/syncthing";
|
|
||||||
user = "syncthing";
|
|
||||||
group = "syncthing";
|
|
||||||
mode = "0700";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
topology.self.interfaces.wg = {
|
topology.self.interfaces.wg = {
|
||||||
|
|
@ -2748,44 +2737,10 @@ This machine mainly acts as an external sync helper. It manages the following th
|
||||||
|
|
||||||
system.stateVersion = "23.11";
|
system.stateVersion = "23.11";
|
||||||
|
|
||||||
globals.services."syncthing-${config.networking.hostName}".domain = serviceDomain;
|
services.syncthing = {
|
||||||
|
dataDir = lib.mkForce "/sync";
|
||||||
services = {
|
|
||||||
nginx = {
|
|
||||||
virtualHosts = {
|
|
||||||
${serviceDomain} = {
|
|
||||||
enableACME = true;
|
|
||||||
forceSSL = true;
|
|
||||||
acmeRoot = null;
|
|
||||||
locations = {
|
|
||||||
"/" = {
|
|
||||||
proxyPass = "http://localhost:8384";
|
|
||||||
extraConfig = ''
|
|
||||||
client_max_body_size 0;
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
syncthing = {
|
|
||||||
enable = true;
|
|
||||||
guiAddress = "0.0.0.0:8384";
|
|
||||||
openDefaultPorts = true;
|
|
||||||
relay.enable = false;
|
|
||||||
settings = {
|
settings = {
|
||||||
urAccepted = -1;
|
devices = config.swarselsystems.syncthing.devices // {
|
||||||
devices = {
|
|
||||||
"magicant" = {
|
|
||||||
id = "VMWGEE2-4HDS2QO-KNQOVGN-LXLX6LA-666E4EK-ZBRYRRO-XFEX6FB-6E3XLQO";
|
|
||||||
};
|
|
||||||
"winters" = {
|
|
||||||
id = "O7RWDMD-AEAHPP7-7TAVLKZ-BSWNBTU-2VA44MS-EYGUNBB-SLHKB3C-ZSLMOAA";
|
|
||||||
};
|
|
||||||
"${workHostName}" = {
|
|
||||||
id = "YAPV4BV-I26WPTN-SIP32MV-SQP5TBZ-3CHMTCI-Z3D6EP2-MNDQGLP-53FT3AB";
|
|
||||||
};
|
|
||||||
"${dev1}" = {
|
"${dev1}" = {
|
||||||
id = "OCCDGDF-IPZ6HHQ-5SSLQ3L-MSSL5ZW-IX5JTAM-PW4PYEK-BRNMJ7E-Q7YDMA7";
|
id = "OCCDGDF-IPZ6HHQ-5SSLQ3L-MSSL5ZW-IX5JTAM-PW4PYEK-BRNMJ7E-Q7YDMA7";
|
||||||
};
|
};
|
||||||
|
|
@ -2797,43 +2752,6 @@ This machine mainly acts as an external sync helper. It manages the following th
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
folders = {
|
folders = {
|
||||||
"Default Folder" = lib.mkForce {
|
|
||||||
path = "/sync/Sync";
|
|
||||||
type = "receiveonly";
|
|
||||||
versioning = null;
|
|
||||||
devices = [ "winters" "magicant" "${workHostName}" ];
|
|
||||||
id = "default";
|
|
||||||
};
|
|
||||||
"Obsidian" = {
|
|
||||||
path = "/sync/Obsidian";
|
|
||||||
type = "receiveonly";
|
|
||||||
versioning = {
|
|
||||||
type = "simple";
|
|
||||||
params.keep = "5";
|
|
||||||
};
|
|
||||||
devices = [ "winters" "magicant" "${workHostName}" ];
|
|
||||||
id = "yjvni-9eaa7";
|
|
||||||
};
|
|
||||||
"Org" = {
|
|
||||||
path = "/sync/Org";
|
|
||||||
type = "receiveonly";
|
|
||||||
versioning = {
|
|
||||||
type = "simple";
|
|
||||||
params.keep = "5";
|
|
||||||
};
|
|
||||||
devices = [ "winters" "magicant" "${workHostName}" ];
|
|
||||||
id = "a7xnl-zjj3d";
|
|
||||||
};
|
|
||||||
"Vpn" = {
|
|
||||||
path = "/sync/Vpn";
|
|
||||||
type = "receiveonly";
|
|
||||||
versioning = {
|
|
||||||
type = "simple";
|
|
||||||
params.keep = "5";
|
|
||||||
};
|
|
||||||
devices = [ "winters" "magicant" "${workHostName}" ];
|
|
||||||
id = "hgp9s-fyq3p";
|
|
||||||
};
|
|
||||||
"Documents" = {
|
"Documents" = {
|
||||||
path = "/sync/Documents";
|
path = "/sync/Documents";
|
||||||
type = "receiveonly";
|
type = "receiveonly";
|
||||||
|
|
@ -2841,7 +2759,7 @@ This machine mainly acts as an external sync helper. It manages the following th
|
||||||
type = "simple";
|
type = "simple";
|
||||||
params.keep = "2";
|
params.keep = "2";
|
||||||
};
|
};
|
||||||
devices = [ "winters" ];
|
devices = [ "pyramid" ];
|
||||||
id = "hgr3d-pfu3w";
|
id = "hgr3d-pfu3w";
|
||||||
};
|
};
|
||||||
"runandbun" = {
|
"runandbun" = {
|
||||||
|
|
@ -2867,7 +2785,6 @@ This machine mainly acts as an external sync helper. It manages the following th
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
swarselprofiles = {
|
swarselprofiles = {
|
||||||
server.moonside = true;
|
server.moonside = true;
|
||||||
|
|
@ -2883,6 +2800,10 @@ This machine mainly acts as an external sync helper. It manages the following th
|
||||||
isBtrfs = true;
|
isBtrfs = true;
|
||||||
isNixos = true;
|
isNixos = true;
|
||||||
isLinux = true;
|
isLinux = true;
|
||||||
|
syncthing = {
|
||||||
|
serviceDomain = config.repo.secrets.common.services.domains.syncthing3;
|
||||||
|
serviceIP = "localhost";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5189,6 +5110,7 @@ Here I disable global completion to prevent redundant compinit calls and cache i
|
||||||
{ lib, config, pkgs, ... }:
|
{ lib, config, pkgs, ... }:
|
||||||
let
|
let
|
||||||
inherit (config.swarselsystems) mainUser homeDir;
|
inherit (config.swarselsystems) mainUser homeDir;
|
||||||
|
devices = config.swarselsystems.syncthing.syncDevices;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.swarselmodules.syncthing = lib.mkEnableOption "syncthing config";
|
options.swarselmodules.syncthing = lib.mkEnableOption "syncthing config";
|
||||||
|
|
@ -5206,39 +5128,26 @@ Here I disable global completion to prevent redundant compinit calls and cache i
|
||||||
options = {
|
options = {
|
||||||
urAccepted = -1;
|
urAccepted = -1;
|
||||||
};
|
};
|
||||||
devices = {
|
inherit (config.swarselsystems.syncthing) devices;
|
||||||
"magicant" = {
|
|
||||||
id = "VMWGEE2-4HDS2QO-KNQOVGN-LXLX6LA-666E4EK-ZBRYRRO-XFEX6FB-6E3XLQO";
|
|
||||||
};
|
|
||||||
"sync@oracle" = {
|
|
||||||
id = "ETW6TST-NPK7MKZ-M4LXMHA-QUPQHDT-VTSHH5X-CR5EIN2-YU7E55F-MGT7DQB";
|
|
||||||
};
|
|
||||||
"winters" = {
|
|
||||||
id = "O7RWDMD-AEAHPP7-7TAVLKZ-BSWNBTU-2VA44MS-EYGUNBB-SLHKB3C-ZSLMOAA";
|
|
||||||
};
|
|
||||||
"moonside@oracle" = {
|
|
||||||
id = "VPCDZB6-MGVGQZD-Q6DIZW3-IZJRJTO-TCC3QUQ-2BNTL7P-AKE7FBO-N55UNQE";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
folders = {
|
folders = {
|
||||||
"Default Folder" = lib.mkDefault {
|
"Default Folder" = lib.mkDefault {
|
||||||
path = "${homeDir}/Sync";
|
path = "${homeDir}/Sync";
|
||||||
devices = [ "sync@oracle" "magicant" "winters" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "default";
|
id = "default";
|
||||||
};
|
};
|
||||||
"Obsidian" = {
|
"Obsidian" = {
|
||||||
path = "${homeDir}/Nextcloud/Obsidian";
|
path = "${homeDir}/Nextcloud/Obsidian";
|
||||||
devices = [ "sync@oracle" "magicant" "winters" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "yjvni-9eaa7";
|
id = "yjvni-9eaa7";
|
||||||
};
|
};
|
||||||
"Org" = {
|
"Org" = {
|
||||||
path = "${homeDir}/Nextcloud/Org";
|
path = "${homeDir}/Nextcloud/Org";
|
||||||
devices = [ "sync@oracle" "magicant" "winters" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "a7xnl-zjj3d";
|
id = "a7xnl-zjj3d";
|
||||||
};
|
};
|
||||||
"Vpn" = {
|
"Vpn" = {
|
||||||
path = "${homeDir}/Vpn";
|
path = "${homeDir}/Vpn";
|
||||||
devices = [ "sync@oracle" "magicant" "winters" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "hgp9s-fyq3p";
|
id = "hgp9s-fyq3p";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -7522,20 +7431,55 @@ Also I install Tika and Gotenberg, which are needed to create PDFs out of =.eml=
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
#+begin_src nix-ts :tangle modules/nixos/server/syncthing.nix
|
#+begin_src nix-ts :tangle modules/nixos/server/syncthing.nix
|
||||||
{ lib, config, ... }:
|
{ lib, config, configName, ... }:
|
||||||
let
|
let
|
||||||
inherit (config.repo.secrets.common) workHostName;
|
|
||||||
|
|
||||||
servicePort = 8384;
|
servicePort = 8384;
|
||||||
serviceUser = "syncthing";
|
serviceUser = "syncthing";
|
||||||
serviceGroup = serviceUser;
|
serviceGroup = serviceUser;
|
||||||
serviceName = "syncthing";
|
serviceName = "syncthing";
|
||||||
serviceDomain = config.repo.secrets.common.services.domains.syncthing1;
|
specificServiceName = "syncthing-${configName}";
|
||||||
|
inherit (config.swarselsystems.syncthing) serviceDomain;
|
||||||
|
inherit (config.swarselsystems.syncthing) serviceIP;
|
||||||
|
|
||||||
cfg = config.services.${serviceName};
|
cfg = config.services.${serviceName};
|
||||||
|
devices = config.swarselsystems.syncthing.syncDevices;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.swarselmodules.server.${serviceName} = lib.mkEnableOption "enable ${serviceName} on server";
|
options = {
|
||||||
|
swarselmodules.server.${serviceName} = lib.mkEnableOption "enable ${serviceName} on server";
|
||||||
|
|
||||||
|
swarselsystems.syncthing = {
|
||||||
|
serviceDomain = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = config.repo.secrets.common.services.domains.syncthing1;
|
||||||
|
};
|
||||||
|
serviceIP = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "192.168.1.2";
|
||||||
|
};
|
||||||
|
syncDevices = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ "magicant" "winters" "pyramid" "moonside@oracle" ];
|
||||||
|
};
|
||||||
|
devices = lib.mkOption {
|
||||||
|
type = lib.types.attrs;
|
||||||
|
default = {
|
||||||
|
"magicant" = {
|
||||||
|
id = "VMWGEE2-4HDS2QO-KNQOVGN-LXLX6LA-666E4EK-ZBRYRRO-XFEX6FB-6E3XLQO";
|
||||||
|
};
|
||||||
|
"winters" = {
|
||||||
|
id = "O7RWDMD-AEAHPP7-7TAVLKZ-BSWNBTU-2VA44MS-EYGUNBB-SLHKB3C-ZSLMOAA";
|
||||||
|
};
|
||||||
|
"moonside@oracle" = {
|
||||||
|
id = "VPCDZB6-MGVGQZD-Q6DIZW3-IZJRJTO-TCC3QUQ-2BNTL7P-AKE7FBO-N55UNQE";
|
||||||
|
};
|
||||||
|
"pyramid" = {
|
||||||
|
id = "YAPV4BV-I26WPTN-SIP32MV-SQP5TBZ-3CHMTCI-Z3D6EP2-MNDQGLP-53FT3AB";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
config = lib.mkIf config.swarselmodules.server.${serviceName} {
|
config = lib.mkIf config.swarselmodules.server.${serviceName} {
|
||||||
|
|
||||||
users.users.${serviceUser} = {
|
users.users.${serviceUser} = {
|
||||||
|
|
@ -7548,39 +7492,26 @@ Also I install Tika and Gotenberg, which are needed to create PDFs out of =.eml=
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [ servicePort ];
|
networking.firewall.allowedTCPPorts = [ servicePort ];
|
||||||
|
|
||||||
globals.services."${serviceName}-${config.networking.hostName}".domain = serviceDomain;
|
globals.services."${specificServiceName}".domain = serviceDomain;
|
||||||
|
|
||||||
services.${serviceName} = rec {
|
services.${serviceName} = rec {
|
||||||
enable = true;
|
enable = true;
|
||||||
user = serviceUser;
|
user = serviceUser;
|
||||||
group = serviceGroup;
|
group = serviceGroup;
|
||||||
dataDir = "/Vault/data/${serviceName}";
|
dataDir = lib.mkDefault "/Vault/data/${serviceName}";
|
||||||
configDir = "${cfg.dataDir}/.config/${serviceName}";
|
configDir = "${cfg.dataDir}/.config/${serviceName}";
|
||||||
guiAddress = "0.0.0.0:${builtins.toString servicePort}";
|
guiAddress = "0.0.0.0:${builtins.toString servicePort}";
|
||||||
openDefaultPorts = true; # opens ports TCP/UDP 22000 and UDP 21027 for discovery
|
openDefaultPorts = true; # opens ports TCP/UDP 22000 and UDP 21027 for discovery
|
||||||
relay.enable = false;
|
relay.enable = false;
|
||||||
settings = {
|
settings = {
|
||||||
urAccepted = -1;
|
urAccepted = -1;
|
||||||
devices = {
|
inherit (config.swarselsystems.syncthing) devices;
|
||||||
"magicant" = {
|
|
||||||
id = "VMWGEE2-4HDS2QO-KNQOVGN-LXLX6LA-666E4EK-ZBRYRRO-XFEX6FB-6E3XLQO";
|
|
||||||
};
|
|
||||||
"milkywell@oracle" = {
|
|
||||||
id = "ETW6TST-NPK7MKZ-M4LXMHA-QUPQHDT-VTSHH5X-CR5EIN2-YU7E55F-MGT7DQB";
|
|
||||||
};
|
|
||||||
"${workHostName}" = {
|
|
||||||
id = "YAPV4BV-I26WPTN-SIP32MV-SQP5TBZ-3CHMTCI-Z3D6EP2-MNDQGLP-53FT3AB";
|
|
||||||
};
|
|
||||||
"moonside@oracle" = {
|
|
||||||
id = "VPCDZB6-MGVGQZD-Q6DIZW3-IZJRJTO-TCC3QUQ-2BNTL7P-AKE7FBO-N55UNQE";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
folders = {
|
folders = {
|
||||||
"Default Folder" = lib.mkForce {
|
"Default Folder" = lib.mkForce {
|
||||||
path = "${cfg.dataDir}/Sync";
|
path = "${cfg.dataDir}/Sync";
|
||||||
type = "receiveonly";
|
type = "receiveonly";
|
||||||
versioning = null;
|
versioning = null;
|
||||||
devices = [ "milkywell@oracle" "magicant" "${workHostName}" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "default";
|
id = "default";
|
||||||
};
|
};
|
||||||
"Obsidian" = {
|
"Obsidian" = {
|
||||||
|
|
@ -7590,7 +7521,7 @@ Also I install Tika and Gotenberg, which are needed to create PDFs out of =.eml=
|
||||||
type = "simple";
|
type = "simple";
|
||||||
params.keep = "5";
|
params.keep = "5";
|
||||||
};
|
};
|
||||||
devices = [ "milkywell@oracle" "magicant" "${workHostName}" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "yjvni-9eaa7";
|
id = "yjvni-9eaa7";
|
||||||
};
|
};
|
||||||
"Org" = {
|
"Org" = {
|
||||||
|
|
@ -7600,7 +7531,7 @@ Also I install Tika and Gotenberg, which are needed to create PDFs out of =.eml=
|
||||||
type = "simple";
|
type = "simple";
|
||||||
params.keep = "5";
|
params.keep = "5";
|
||||||
};
|
};
|
||||||
devices = [ "milkywell@oracle" "magicant" "${workHostName}" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "a7xnl-zjj3d";
|
id = "a7xnl-zjj3d";
|
||||||
};
|
};
|
||||||
"Vpn" = {
|
"Vpn" = {
|
||||||
|
|
@ -7610,28 +7541,18 @@ Also I install Tika and Gotenberg, which are needed to create PDFs out of =.eml=
|
||||||
type = "simple";
|
type = "simple";
|
||||||
params.keep = "5";
|
params.keep = "5";
|
||||||
};
|
};
|
||||||
devices = [ "milkywell@oracle" "magicant" "${workHostName}" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "hgp9s-fyq3p";
|
id = "hgp9s-fyq3p";
|
||||||
};
|
};
|
||||||
# "Documents" = {
|
|
||||||
# path = "${cfg.dataDir}/Documents";
|
|
||||||
# type = "receiveonly";
|
|
||||||
# versioning = {
|
|
||||||
# type = "simple";
|
|
||||||
# params.keep = "5";
|
|
||||||
# };
|
|
||||||
# devices = [ "magicant" "${workHostName}" "moonside@oracle" ];
|
|
||||||
# id = "hgr3d-pfu3w";
|
|
||||||
# };
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nodes.moonside.services.nginx = {
|
nodes.moonside.services.nginx = {
|
||||||
upstreams = {
|
upstreams = {
|
||||||
${serviceName} = {
|
${specificServiceName} = {
|
||||||
servers = {
|
servers = {
|
||||||
"192.168.1.2:${builtins.toString servicePort}" = { };
|
"${serviceIP}:${builtins.toString servicePort}" = { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -7642,7 +7563,7 @@ Also I install Tika and Gotenberg, which are needed to create PDFs out of =.eml=
|
||||||
acmeRoot = null;
|
acmeRoot = null;
|
||||||
locations = {
|
locations = {
|
||||||
"/" = {
|
"/" = {
|
||||||
proxyPass = "http://${serviceName}";
|
proxyPass = "http://${specificServiceName}";
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
client_max_body_size 0;
|
client_max_body_size 0;
|
||||||
'';
|
'';
|
||||||
|
|
@ -16693,6 +16614,7 @@ Modules that need to be loaded on the NixOS level. Note that these will not be a
|
||||||
microbin = lib.mkDefault true;
|
microbin = lib.mkDefault true;
|
||||||
shlink = lib.mkDefault true;
|
shlink = lib.mkDefault true;
|
||||||
slink = lib.mkDefault true;
|
slink = lib.mkDefault true;
|
||||||
|
syncthing = lib.mkDefault true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
{ lib, config, globals, ... }:
|
{ lib, config, ... }:
|
||||||
let
|
let
|
||||||
inherit (config.repo.secrets.common) workHostName;
|
|
||||||
inherit (config.repo.secrets.local.syncthing) dev1 dev2 dev3 loc1;
|
inherit (config.repo.secrets.local.syncthing) dev1 dev2 dev3 loc1;
|
||||||
inherit (config.swarselsystems) sopsFile;
|
inherit (config.swarselsystems) sopsFile;
|
||||||
serviceDomain = config.repo.secrets.common.services.domains.syncthing3;
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
|
@ -26,15 +24,6 @@ in
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
etc."issue".text = "\4";
|
etc."issue".text = "\4";
|
||||||
|
|
||||||
persistence."/persist".directories = lib.mkIf config.swarselsystems.isImpermanence [
|
|
||||||
{
|
|
||||||
directory = "/var/lib/syncthing";
|
|
||||||
user = "syncthing";
|
|
||||||
group = "syncthing";
|
|
||||||
mode = "0700";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
topology.self.interfaces.wg = {
|
topology.self.interfaces.wg = {
|
||||||
|
|
@ -81,44 +70,10 @@ in
|
||||||
|
|
||||||
system.stateVersion = "23.11";
|
system.stateVersion = "23.11";
|
||||||
|
|
||||||
globals.services."syncthing-${config.networking.hostName}".domain = serviceDomain;
|
services.syncthing = {
|
||||||
|
dataDir = lib.mkForce "/sync";
|
||||||
services = {
|
|
||||||
nginx = {
|
|
||||||
virtualHosts = {
|
|
||||||
${serviceDomain} = {
|
|
||||||
enableACME = true;
|
|
||||||
forceSSL = true;
|
|
||||||
acmeRoot = null;
|
|
||||||
locations = {
|
|
||||||
"/" = {
|
|
||||||
proxyPass = "http://localhost:8384";
|
|
||||||
extraConfig = ''
|
|
||||||
client_max_body_size 0;
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
syncthing = {
|
|
||||||
enable = true;
|
|
||||||
guiAddress = "0.0.0.0:8384";
|
|
||||||
openDefaultPorts = true;
|
|
||||||
relay.enable = false;
|
|
||||||
settings = {
|
settings = {
|
||||||
urAccepted = -1;
|
devices = config.swarselsystems.syncthing.devices // {
|
||||||
devices = {
|
|
||||||
"magicant" = {
|
|
||||||
id = "VMWGEE2-4HDS2QO-KNQOVGN-LXLX6LA-666E4EK-ZBRYRRO-XFEX6FB-6E3XLQO";
|
|
||||||
};
|
|
||||||
"winters" = {
|
|
||||||
id = "O7RWDMD-AEAHPP7-7TAVLKZ-BSWNBTU-2VA44MS-EYGUNBB-SLHKB3C-ZSLMOAA";
|
|
||||||
};
|
|
||||||
"${workHostName}" = {
|
|
||||||
id = "YAPV4BV-I26WPTN-SIP32MV-SQP5TBZ-3CHMTCI-Z3D6EP2-MNDQGLP-53FT3AB";
|
|
||||||
};
|
|
||||||
"${dev1}" = {
|
"${dev1}" = {
|
||||||
id = "OCCDGDF-IPZ6HHQ-5SSLQ3L-MSSL5ZW-IX5JTAM-PW4PYEK-BRNMJ7E-Q7YDMA7";
|
id = "OCCDGDF-IPZ6HHQ-5SSLQ3L-MSSL5ZW-IX5JTAM-PW4PYEK-BRNMJ7E-Q7YDMA7";
|
||||||
};
|
};
|
||||||
|
|
@ -130,43 +85,6 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
folders = {
|
folders = {
|
||||||
"Default Folder" = lib.mkForce {
|
|
||||||
path = "/sync/Sync";
|
|
||||||
type = "receiveonly";
|
|
||||||
versioning = null;
|
|
||||||
devices = [ "winters" "magicant" "${workHostName}" ];
|
|
||||||
id = "default";
|
|
||||||
};
|
|
||||||
"Obsidian" = {
|
|
||||||
path = "/sync/Obsidian";
|
|
||||||
type = "receiveonly";
|
|
||||||
versioning = {
|
|
||||||
type = "simple";
|
|
||||||
params.keep = "5";
|
|
||||||
};
|
|
||||||
devices = [ "winters" "magicant" "${workHostName}" ];
|
|
||||||
id = "yjvni-9eaa7";
|
|
||||||
};
|
|
||||||
"Org" = {
|
|
||||||
path = "/sync/Org";
|
|
||||||
type = "receiveonly";
|
|
||||||
versioning = {
|
|
||||||
type = "simple";
|
|
||||||
params.keep = "5";
|
|
||||||
};
|
|
||||||
devices = [ "winters" "magicant" "${workHostName}" ];
|
|
||||||
id = "a7xnl-zjj3d";
|
|
||||||
};
|
|
||||||
"Vpn" = {
|
|
||||||
path = "/sync/Vpn";
|
|
||||||
type = "receiveonly";
|
|
||||||
versioning = {
|
|
||||||
type = "simple";
|
|
||||||
params.keep = "5";
|
|
||||||
};
|
|
||||||
devices = [ "winters" "magicant" "${workHostName}" ];
|
|
||||||
id = "hgp9s-fyq3p";
|
|
||||||
};
|
|
||||||
"Documents" = {
|
"Documents" = {
|
||||||
path = "/sync/Documents";
|
path = "/sync/Documents";
|
||||||
type = "receiveonly";
|
type = "receiveonly";
|
||||||
|
|
@ -174,7 +92,7 @@ in
|
||||||
type = "simple";
|
type = "simple";
|
||||||
params.keep = "2";
|
params.keep = "2";
|
||||||
};
|
};
|
||||||
devices = [ "winters" ];
|
devices = [ "pyramid" ];
|
||||||
id = "hgr3d-pfu3w";
|
id = "hgr3d-pfu3w";
|
||||||
};
|
};
|
||||||
"runandbun" = {
|
"runandbun" = {
|
||||||
|
|
@ -200,7 +118,6 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
swarselprofiles = {
|
swarselprofiles = {
|
||||||
server.moonside = true;
|
server.moonside = true;
|
||||||
|
|
@ -216,5 +133,9 @@ in
|
||||||
isBtrfs = true;
|
isBtrfs = true;
|
||||||
isNixos = true;
|
isNixos = true;
|
||||||
isLinux = true;
|
isLinux = true;
|
||||||
|
syncthing = {
|
||||||
|
serviceDomain = config.repo.secrets.common.services.domains.syncthing3;
|
||||||
|
serviceIP = "localhost";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
{ lib, config, pkgs, ... }:
|
{ lib, config, pkgs, ... }:
|
||||||
let
|
let
|
||||||
inherit (config.swarselsystems) mainUser homeDir;
|
inherit (config.swarselsystems) mainUser homeDir;
|
||||||
|
devices = config.swarselsystems.syncthing.syncDevices;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.swarselmodules.syncthing = lib.mkEnableOption "syncthing config";
|
options.swarselmodules.syncthing = lib.mkEnableOption "syncthing config";
|
||||||
|
|
@ -18,39 +19,26 @@ in
|
||||||
options = {
|
options = {
|
||||||
urAccepted = -1;
|
urAccepted = -1;
|
||||||
};
|
};
|
||||||
devices = {
|
inherit (config.swarselsystems.syncthing) devices;
|
||||||
"magicant" = {
|
|
||||||
id = "VMWGEE2-4HDS2QO-KNQOVGN-LXLX6LA-666E4EK-ZBRYRRO-XFEX6FB-6E3XLQO";
|
|
||||||
};
|
|
||||||
"sync@oracle" = {
|
|
||||||
id = "ETW6TST-NPK7MKZ-M4LXMHA-QUPQHDT-VTSHH5X-CR5EIN2-YU7E55F-MGT7DQB";
|
|
||||||
};
|
|
||||||
"winters" = {
|
|
||||||
id = "O7RWDMD-AEAHPP7-7TAVLKZ-BSWNBTU-2VA44MS-EYGUNBB-SLHKB3C-ZSLMOAA";
|
|
||||||
};
|
|
||||||
"moonside@oracle" = {
|
|
||||||
id = "VPCDZB6-MGVGQZD-Q6DIZW3-IZJRJTO-TCC3QUQ-2BNTL7P-AKE7FBO-N55UNQE";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
folders = {
|
folders = {
|
||||||
"Default Folder" = lib.mkDefault {
|
"Default Folder" = lib.mkDefault {
|
||||||
path = "${homeDir}/Sync";
|
path = "${homeDir}/Sync";
|
||||||
devices = [ "sync@oracle" "magicant" "winters" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "default";
|
id = "default";
|
||||||
};
|
};
|
||||||
"Obsidian" = {
|
"Obsidian" = {
|
||||||
path = "${homeDir}/Nextcloud/Obsidian";
|
path = "${homeDir}/Nextcloud/Obsidian";
|
||||||
devices = [ "sync@oracle" "magicant" "winters" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "yjvni-9eaa7";
|
id = "yjvni-9eaa7";
|
||||||
};
|
};
|
||||||
"Org" = {
|
"Org" = {
|
||||||
path = "${homeDir}/Nextcloud/Org";
|
path = "${homeDir}/Nextcloud/Org";
|
||||||
devices = [ "sync@oracle" "magicant" "winters" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "a7xnl-zjj3d";
|
id = "a7xnl-zjj3d";
|
||||||
};
|
};
|
||||||
"Vpn" = {
|
"Vpn" = {
|
||||||
path = "${homeDir}/Vpn";
|
path = "${homeDir}/Vpn";
|
||||||
devices = [ "sync@oracle" "magicant" "winters" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "hgp9s-fyq3p";
|
id = "hgp9s-fyq3p";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,52 @@
|
||||||
{ lib, config, ... }:
|
{ lib, config, configName, ... }:
|
||||||
let
|
let
|
||||||
inherit (config.repo.secrets.common) workHostName;
|
|
||||||
|
|
||||||
servicePort = 8384;
|
servicePort = 8384;
|
||||||
serviceUser = "syncthing";
|
serviceUser = "syncthing";
|
||||||
serviceGroup = serviceUser;
|
serviceGroup = serviceUser;
|
||||||
serviceName = "syncthing";
|
serviceName = "syncthing";
|
||||||
serviceDomain = config.repo.secrets.common.services.domains.syncthing1;
|
specificServiceName = "syncthing-${configName}";
|
||||||
|
inherit (config.swarselsystems.syncthing) serviceDomain;
|
||||||
|
inherit (config.swarselsystems.syncthing) serviceIP;
|
||||||
|
|
||||||
cfg = config.services.${serviceName};
|
cfg = config.services.${serviceName};
|
||||||
|
devices = config.swarselsystems.syncthing.syncDevices;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.swarselmodules.server.${serviceName} = lib.mkEnableOption "enable ${serviceName} on server";
|
options = {
|
||||||
|
swarselmodules.server.${serviceName} = lib.mkEnableOption "enable ${serviceName} on server";
|
||||||
|
|
||||||
|
swarselsystems.syncthing = {
|
||||||
|
serviceDomain = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = config.repo.secrets.common.services.domains.syncthing1;
|
||||||
|
};
|
||||||
|
serviceIP = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "192.168.1.2";
|
||||||
|
};
|
||||||
|
syncDevices = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ "magicant" "winters" "pyramid" "moonside@oracle" ];
|
||||||
|
};
|
||||||
|
devices = lib.mkOption {
|
||||||
|
type = lib.types.attrs;
|
||||||
|
default = {
|
||||||
|
"magicant" = {
|
||||||
|
id = "VMWGEE2-4HDS2QO-KNQOVGN-LXLX6LA-666E4EK-ZBRYRRO-XFEX6FB-6E3XLQO";
|
||||||
|
};
|
||||||
|
"winters" = {
|
||||||
|
id = "O7RWDMD-AEAHPP7-7TAVLKZ-BSWNBTU-2VA44MS-EYGUNBB-SLHKB3C-ZSLMOAA";
|
||||||
|
};
|
||||||
|
"moonside@oracle" = {
|
||||||
|
id = "VPCDZB6-MGVGQZD-Q6DIZW3-IZJRJTO-TCC3QUQ-2BNTL7P-AKE7FBO-N55UNQE";
|
||||||
|
};
|
||||||
|
"pyramid" = {
|
||||||
|
id = "YAPV4BV-I26WPTN-SIP32MV-SQP5TBZ-3CHMTCI-Z3D6EP2-MNDQGLP-53FT3AB";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
config = lib.mkIf config.swarselmodules.server.${serviceName} {
|
config = lib.mkIf config.swarselmodules.server.${serviceName} {
|
||||||
|
|
||||||
users.users.${serviceUser} = {
|
users.users.${serviceUser} = {
|
||||||
|
|
@ -24,39 +59,26 @@ in
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [ servicePort ];
|
networking.firewall.allowedTCPPorts = [ servicePort ];
|
||||||
|
|
||||||
globals.services."${serviceName}-${config.networking.hostName}".domain = serviceDomain;
|
globals.services."${specificServiceName}".domain = serviceDomain;
|
||||||
|
|
||||||
services.${serviceName} = rec {
|
services.${serviceName} = rec {
|
||||||
enable = true;
|
enable = true;
|
||||||
user = serviceUser;
|
user = serviceUser;
|
||||||
group = serviceGroup;
|
group = serviceGroup;
|
||||||
dataDir = "/Vault/data/${serviceName}";
|
dataDir = lib.mkDefault "/Vault/data/${serviceName}";
|
||||||
configDir = "${cfg.dataDir}/.config/${serviceName}";
|
configDir = "${cfg.dataDir}/.config/${serviceName}";
|
||||||
guiAddress = "0.0.0.0:${builtins.toString servicePort}";
|
guiAddress = "0.0.0.0:${builtins.toString servicePort}";
|
||||||
openDefaultPorts = true; # opens ports TCP/UDP 22000 and UDP 21027 for discovery
|
openDefaultPorts = true; # opens ports TCP/UDP 22000 and UDP 21027 for discovery
|
||||||
relay.enable = false;
|
relay.enable = false;
|
||||||
settings = {
|
settings = {
|
||||||
urAccepted = -1;
|
urAccepted = -1;
|
||||||
devices = {
|
inherit (config.swarselsystems.syncthing) devices;
|
||||||
"magicant" = {
|
|
||||||
id = "VMWGEE2-4HDS2QO-KNQOVGN-LXLX6LA-666E4EK-ZBRYRRO-XFEX6FB-6E3XLQO";
|
|
||||||
};
|
|
||||||
"milkywell@oracle" = {
|
|
||||||
id = "ETW6TST-NPK7MKZ-M4LXMHA-QUPQHDT-VTSHH5X-CR5EIN2-YU7E55F-MGT7DQB";
|
|
||||||
};
|
|
||||||
"${workHostName}" = {
|
|
||||||
id = "YAPV4BV-I26WPTN-SIP32MV-SQP5TBZ-3CHMTCI-Z3D6EP2-MNDQGLP-53FT3AB";
|
|
||||||
};
|
|
||||||
"moonside@oracle" = {
|
|
||||||
id = "VPCDZB6-MGVGQZD-Q6DIZW3-IZJRJTO-TCC3QUQ-2BNTL7P-AKE7FBO-N55UNQE";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
folders = {
|
folders = {
|
||||||
"Default Folder" = lib.mkForce {
|
"Default Folder" = lib.mkForce {
|
||||||
path = "${cfg.dataDir}/Sync";
|
path = "${cfg.dataDir}/Sync";
|
||||||
type = "receiveonly";
|
type = "receiveonly";
|
||||||
versioning = null;
|
versioning = null;
|
||||||
devices = [ "milkywell@oracle" "magicant" "${workHostName}" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "default";
|
id = "default";
|
||||||
};
|
};
|
||||||
"Obsidian" = {
|
"Obsidian" = {
|
||||||
|
|
@ -66,7 +88,7 @@ in
|
||||||
type = "simple";
|
type = "simple";
|
||||||
params.keep = "5";
|
params.keep = "5";
|
||||||
};
|
};
|
||||||
devices = [ "milkywell@oracle" "magicant" "${workHostName}" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "yjvni-9eaa7";
|
id = "yjvni-9eaa7";
|
||||||
};
|
};
|
||||||
"Org" = {
|
"Org" = {
|
||||||
|
|
@ -76,7 +98,7 @@ in
|
||||||
type = "simple";
|
type = "simple";
|
||||||
params.keep = "5";
|
params.keep = "5";
|
||||||
};
|
};
|
||||||
devices = [ "milkywell@oracle" "magicant" "${workHostName}" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "a7xnl-zjj3d";
|
id = "a7xnl-zjj3d";
|
||||||
};
|
};
|
||||||
"Vpn" = {
|
"Vpn" = {
|
||||||
|
|
@ -86,28 +108,18 @@ in
|
||||||
type = "simple";
|
type = "simple";
|
||||||
params.keep = "5";
|
params.keep = "5";
|
||||||
};
|
};
|
||||||
devices = [ "milkywell@oracle" "magicant" "${workHostName}" "moonside@oracle" ];
|
inherit devices;
|
||||||
id = "hgp9s-fyq3p";
|
id = "hgp9s-fyq3p";
|
||||||
};
|
};
|
||||||
# "Documents" = {
|
|
||||||
# path = "${cfg.dataDir}/Documents";
|
|
||||||
# type = "receiveonly";
|
|
||||||
# versioning = {
|
|
||||||
# type = "simple";
|
|
||||||
# params.keep = "5";
|
|
||||||
# };
|
|
||||||
# devices = [ "magicant" "${workHostName}" "moonside@oracle" ];
|
|
||||||
# id = "hgr3d-pfu3w";
|
|
||||||
# };
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nodes.moonside.services.nginx = {
|
nodes.moonside.services.nginx = {
|
||||||
upstreams = {
|
upstreams = {
|
||||||
${serviceName} = {
|
${specificServiceName} = {
|
||||||
servers = {
|
servers = {
|
||||||
"192.168.1.2:${builtins.toString servicePort}" = { };
|
"${serviceIP}:${builtins.toString servicePort}" = { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -118,7 +130,7 @@ in
|
||||||
acmeRoot = null;
|
acmeRoot = null;
|
||||||
locations = {
|
locations = {
|
||||||
"/" = {
|
"/" = {
|
||||||
proxyPass = "http://${serviceName}";
|
proxyPass = "http://${specificServiceName}";
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
client_max_body_size 0;
|
client_max_body_size 0;
|
||||||
'';
|
'';
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
microbin = lib.mkDefault true;
|
microbin = lib.mkDefault true;
|
||||||
shlink = lib.mkDefault true;
|
shlink = lib.mkDefault true;
|
||||||
slink = lib.mkDefault true;
|
slink = lib.mkDefault true;
|
||||||
|
syncthing = lib.mkDefault true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue