feat(syncthing): adding syncthing host to sobotka
This commit is contained in:
@@ -11,6 +11,20 @@ in
|
||||
{
|
||||
options.server = {
|
||||
enable = lib.mkEnableOption "The server services and configuration variables";
|
||||
mounts.fast = lib.mkOption {
|
||||
default = "/mnt/cache";
|
||||
type = lib.types.path;
|
||||
description = ''
|
||||
Path to the 'fast' tier mount
|
||||
'';
|
||||
};
|
||||
mounts.config = lib.mkOption {
|
||||
default = "/persist/opt/services";
|
||||
type = lib.types.path;
|
||||
description = ''
|
||||
Path to the service configuration files
|
||||
'';
|
||||
};
|
||||
email = mkOption {
|
||||
default = "";
|
||||
type = types.str;
|
||||
@@ -53,7 +67,6 @@ in
|
||||
GID to run the server services as
|
||||
'';
|
||||
};
|
||||
|
||||
timeZone = lib.mkOption {
|
||||
default = "Europe/Stockholm";
|
||||
type = lib.types.str;
|
||||
@@ -62,6 +75,7 @@ in
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
users = {
|
||||
groups.${cfg.group} = {
|
||||
|
||||
68
modules/server/syncthing/default.nix
Normal file
68
modules/server/syncthing/default.nix
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
unit = "syncthing";
|
||||
srv = config.server;
|
||||
cfg = config.server.${unit};
|
||||
dir = [
|
||||
"${srv.mounts.config}/syncthing"
|
||||
];
|
||||
in
|
||||
{
|
||||
options.server.${unit} = {
|
||||
enable = lib.mkEnableOption {
|
||||
description = "Enable ${unit}";
|
||||
};
|
||||
url = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "${unit}.${srv.domain}";
|
||||
};
|
||||
homepage.name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "Syncthing";
|
||||
};
|
||||
homepage.description = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "Continuous file synchronization program.";
|
||||
};
|
||||
homepage.icon = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "syncthing.svg";
|
||||
};
|
||||
homepage.category = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "Services";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.tmpfiles.rules = map (x: "d ${x} 0775 share share - -") dir;
|
||||
networking.firewall = {
|
||||
allowedTCPPorts = [
|
||||
8384
|
||||
22000
|
||||
];
|
||||
allowedUDPPorts = [
|
||||
22000
|
||||
21027
|
||||
];
|
||||
};
|
||||
services.${unit} = {
|
||||
enable = true;
|
||||
user = srv.user;
|
||||
group = srv.group;
|
||||
overrideFolders = false;
|
||||
overrideDevices = false;
|
||||
dataDir = "${srv.mounts.fast}/Syncthing";
|
||||
configDir = "${srv.mounts.config}/syncthing";
|
||||
};
|
||||
services.caddy.virtualHosts."${cfg.url}" = {
|
||||
useACMEHost = srv.domain;
|
||||
extraConfig = ''
|
||||
reverse_proxy http://127.0.0.1:8384}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user