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; ssh.enable = true;
git.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 = { options = {
enable = true; mod.syncthing = {
openDefaultPorts = true; enable = lib.mkEnableOption "Enable syncthing module";
};
};
cert = config.age.secrets.syncthing-cert.path; config = lib.mkIf enabled {
key = config.age.secrets.syncthing-key.path; services.syncthing = {
enable = true;
openDefaultPorts = true;
user = "alex"; cert = config.age.secrets.syncthing-cert.path;
group = "users"; 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 = { guiAddress = "0.0.0.0:8384";
devices = {
phone.id = config.lib.syncthing.phone;
pinwheel.id = config.lib.syncthing.pinwheel;
};
folders = { settings = {
org = { devices = {
path = "/home/alex/sync/org"; phone.id = config.lib.syncthing.phone;
devices = [ "phone" "pinwheel" ]; pinwheel.id = config.lib.syncthing.pinwheel;
versioning = {
type = "staggered";
params = {
maxage = "2592000"; # 30 days
};
};
}; };
personal = { folders = {
path = "/home/alex/sync/personal"; org = {
devices = [ "pinwheel" ]; path = "/home/alex/sync/org";
versioning = { devices = [ "phone" "pinwheel" ];
type = "staggered"; versioning = {
params = { type = "staggered";
maxAge = "2592000"; # 30 days params = {
maxage = "2592000"; # 30 days
};
}; };
}; };
};
work = { personal = {
path = "/home/alex/sync/work"; path = "/home/alex/sync/personal";
devices = [ "pinwheel" ]; devices = [ "pinwheel" ];
versioning = { versioning = {
type = "staggered"; type = "staggered";
params = { params = {
maxAge = "2592000"; # 30 days maxAge = "2592000"; # 30 days
};
}; };
}; };
};
books = { work = {
path = "/home/alex/sync/books"; path = "/home/alex/sync/work";
devices = [ "pinwheel" ]; devices = [ "pinwheel" ];
versioning = { versioning = {
type = "staggered"; type = "staggered";
params = { params = {
maxAge = "2592000"; # 30 days maxAge = "2592000"; # 30 days
};
}; };
}; };
};
"phone-gps" = { books = {
path = "/home/alex/sync/phone-gps"; path = "/home/alex/sync/books";
devices = [ "phone" ]; devices = [ "pinwheel" ];
versioning = { versioning = {
type = "staggered"; type = "staggered";
params = { params = {
maxage = "2592000"; # 30 days maxAge = "2592000"; # 30 days
};
};
};
"phone-gps" = {
path = "/home/alex/sync/phone-gps";
devices = [ "phone" ];
versioning = {
type = "staggered";
params = {
maxage = "2592000"; # 30 days
};
}; };
}; };
}; };
}; };
}; };
};
age = { age = {
secrets = { secrets = {
"syncthing-cert".file = ../../../../secrets/backwards/syncthing-cert.age; "syncthing-cert".file = ../../../../secrets/backwards/syncthing-cert.age;
"syncthing-key".file = ../../../../secrets/backwards/syncthing-key.age; "syncthing-key".file = ../../../../secrets/backwards/syncthing-key.age;
};
}; };
}; };
} }