backwards: Add enable option to syncthing module

This commit is contained in:
Alexander Heldt
2024-08-31 12:45:52 +02:00
parent 0a43eed112
commit 9b98cdfe38
2 changed files with 73 additions and 61 deletions

View File

@@ -12,6 +12,7 @@ in
ssh.enable = true;
git.enable = true;
syncthing.enable = true;
};
};
}

View File

@@ -1,88 +1,99 @@
{ config, ... }:
{ lib, config, ... }:
let
enabled = config.mod.syncthing.enable;
in
{
services.syncthing = {
enable = true;
openDefaultPorts = true;
options = {
mod.syncthing = {
enable = lib.mkEnableOption "Enable syncthing module";
};
};
cert = config.age.secrets.syncthing-cert.path;
key = config.age.secrets.syncthing-key.path;
config = lib.mkIf enabled {
services.syncthing = {
enable = true;
openDefaultPorts = true;
user = "alex";
group = "users";
cert = config.age.secrets.syncthing-cert.path;
key = config.age.secrets.syncthing-key.path;
dataDir = "/home/alex/sync";
user = "alex";
group = "users";
guiAddress = "0.0.0.0:8384";
dataDir = "/home/alex/sync";
settings = {
devices = {
phone.id = config.lib.syncthing.phone;
pinwheel.id = config.lib.syncthing.pinwheel;
};
guiAddress = "0.0.0.0:8384";
folders = {
org = {
path = "/home/alex/sync/org";
devices = [ "phone" "pinwheel" ];
versioning = {
type = "staggered";
params = {
maxage = "2592000"; # 30 days
};
};
settings = {
devices = {
phone.id = config.lib.syncthing.phone;
pinwheel.id = config.lib.syncthing.pinwheel;
};
personal = {
path = "/home/alex/sync/personal";
devices = [ "pinwheel" ];
versioning = {
type = "staggered";
params = {
maxAge = "2592000"; # 30 days
folders = {
org = {
path = "/home/alex/sync/org";
devices = [ "phone" "pinwheel" ];
versioning = {
type = "staggered";
params = {
maxage = "2592000"; # 30 days
};
};
};
};
work = {
path = "/home/alex/sync/work";
devices = [ "pinwheel" ];
versioning = {
type = "staggered";
params = {
maxAge = "2592000"; # 30 days
personal = {
path = "/home/alex/sync/personal";
devices = [ "pinwheel" ];
versioning = {
type = "staggered";
params = {
maxAge = "2592000"; # 30 days
};
};
};
};
books = {
path = "/home/alex/sync/books";
devices = [ "pinwheel" ];
versioning = {
type = "staggered";
params = {
maxAge = "2592000"; # 30 days
work = {
path = "/home/alex/sync/work";
devices = [ "pinwheel" ];
versioning = {
type = "staggered";
params = {
maxAge = "2592000"; # 30 days
};
};
};
};
"phone-gps" = {
path = "/home/alex/sync/phone-gps";
devices = [ "phone" ];
versioning = {
type = "staggered";
params = {
maxage = "2592000"; # 30 days
books = {
path = "/home/alex/sync/books";
devices = [ "pinwheel" ];
versioning = {
type = "staggered";
params = {
maxAge = "2592000"; # 30 days
};
};
};
"phone-gps" = {
path = "/home/alex/sync/phone-gps";
devices = [ "phone" ];
versioning = {
type = "staggered";
params = {
maxage = "2592000"; # 30 days
};
};
};
};
};
};
};
age = {
secrets = {
"syncthing-cert".file = ../../../../secrets/backwards/syncthing-cert.age;
"syncthing-key".file = ../../../../secrets/backwards/syncthing-key.age;
age = {
secrets = {
"syncthing-cert".file = ../../../../secrets/backwards/syncthing-cert.age;
"syncthing-key".file = ../../../../secrets/backwards/syncthing-key.age;
};
};
};
}