nixos/syncthing: improve code readability

This commit is contained in:
Aly Raffauf 2024-07-06 10:56:05 -04:00
parent 73672c4912
commit 12fc4b744f

View file

@ -6,7 +6,10 @@
}: { }: {
imports = [./syncMusic.nix]; imports = [./syncMusic.nix];
config = lib.mkIf config.ar.services.syncthing.enable { config = let
cfg = config.ar.services.syncthing;
in
lib.mkIf cfg.enable {
age.secrets = { age.secrets = {
syncthingCert.file = ../../../secrets/syncthing + "/${config.networking.hostName}/cert.age"; syncthingCert.file = ../../../secrets/syncthing + "/${config.networking.hostName}/cert.age";
syncthingKey.file = ../../../secrets/syncthing + "/${config.networking.hostName}/key.age"; syncthingKey.file = ../../../secrets/syncthing + "/${config.networking.hostName}/key.age";
@ -17,10 +20,10 @@
services.syncthing = { services.syncthing = {
enable = true; enable = true;
cert = config.age.secrets.syncthingCert.path; cert = config.age.secrets.syncthingCert.path;
dataDir = "/home/${config.ar.services.syncthing.user}"; dataDir = "/home/${cfg.user}";
key = config.age.secrets.syncthingKey.path; key = config.age.secrets.syncthingKey.path;
openDefaultPorts = true; openDefaultPorts = true;
user = config.ar.services.syncthing.user; user = cfg.user;
settings = { settings = {
options = { options = {
localAnnounceEnabled = true; localAnnounceEnabled = true;
@ -43,7 +46,7 @@
folders = { folders = {
"sync" = { "sync" = {
id = "default"; id = "default";
path = "/home/${config.ar.services.syncthing.user}/sync"; path = "/home/${cfg.user}/sync";
devices = ["brawly" "fallarbor" "gsgmba" "iphone12" "lavaridge" "mauville" "petalburg" "rustboro" "mossdeep" "wallace" "winona"]; devices = ["brawly" "fallarbor" "gsgmba" "iphone12" "lavaridge" "mauville" "petalburg" "rustboro" "mossdeep" "wallace" "winona"];
versioning = { versioning = {
type = "staggered"; type = "staggered";
@ -55,7 +58,7 @@
}; };
"camera" = { "camera" = {
id = "fcsgh-dlxys"; id = "fcsgh-dlxys";
path = "/home/${config.ar.services.syncthing.user}/pics/camera"; path = "/home/${cfg.user}/pics/camera";
devices = ["brawly" "fallarbor" "lavaridge" "mauville" "petalburg" "rustboro" "wallace" "winona"]; devices = ["brawly" "fallarbor" "lavaridge" "mauville" "petalburg" "rustboro" "wallace" "winona"];
versioning = { versioning = {
params.cleanoutDays = "5"; params.cleanoutDays = "5";
@ -64,7 +67,7 @@
}; };
"screenshots" = { "screenshots" = {
id = "screenshots"; id = "screenshots";
path = "/home/${config.ar.services.syncthing.user}/pics/screenshots"; path = "/home/${cfg.user}/pics/screenshots";
devices = ["brawly" "fallarbor" "lavaridge" "mauville" "petalburg" "rustboro" "wallace" "winona"]; devices = ["brawly" "fallarbor" "lavaridge" "mauville" "petalburg" "rustboro" "wallace" "winona"];
versioning = { versioning = {
params.cleanoutDays = "5"; params.cleanoutDays = "5";