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,73 +6,76 @@
}: { }: {
imports = [./syncMusic.nix]; imports = [./syncMusic.nix];
config = lib.mkIf config.ar.services.syncthing.enable { config = let
age.secrets = { cfg = config.ar.services.syncthing;
syncthingCert.file = ../../../secrets/syncthing + "/${config.networking.hostName}/cert.age"; in
syncthingKey.file = ../../../secrets/syncthing + "/${config.networking.hostName}/key.age"; lib.mkIf cfg.enable {
}; age.secrets = {
syncthingCert.file = ../../../secrets/syncthing + "/${config.networking.hostName}/cert.age";
syncthingKey.file = ../../../secrets/syncthing + "/${config.networking.hostName}/key.age";
};
systemd.services.syncthing.environment.STNODEFAULTFOLDER = "true"; systemd.services.syncthing.environment.STNODEFAULTFOLDER = "true";
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;
relaysEnabled = true; relaysEnabled = true;
urAccepted = -1; urAccepted = -1;
}; };
devices = { devices = {
"brawly" = {id = "BBIBWMR-CN4CFC4-2XMPLII-XFWXBT5-EPCZCAF-JOWAX5J-DHIGNM4-O3XQ4Q3";}; # Pixel 6a "brawly" = {id = "BBIBWMR-CN4CFC4-2XMPLII-XFWXBT5-EPCZCAF-JOWAX5J-DHIGNM4-O3XQ4Q3";}; # Pixel 6a
"fallarbor" = {id = "P4URLH4-YWLMO6J-W62ET7H-TQAO3Y6-T2FAYOY-C2VTI65-VQXHVGG-NQ76PAZ";}; # Framework 13 Intel 11th gen "fallarbor" = {id = "P4URLH4-YWLMO6J-W62ET7H-TQAO3Y6-T2FAYOY-C2VTI65-VQXHVGG-NQ76PAZ";}; # Framework 13 Intel 11th gen
"gsgmba" = {id = "V2YCZSL-XY7H72L-FGJFWP2-JNYX72O-OJ5V2HY-V4SSSJM-77A7E3Z-7EJFAAV";}; # Work Macbook Air "gsgmba" = {id = "V2YCZSL-XY7H72L-FGJFWP2-JNYX72O-OJ5V2HY-V4SSSJM-77A7E3Z-7EJFAAV";}; # Work Macbook Air
"iphone12" = {id = "SBQNUXS-H4XDJ3E-RBHJPT5-45WDJJA-2U43M4P-23XGUJ7-E3CNNKZ-BXSGIA3";}; # iPhone 12 Pro Max "iphone12" = {id = "SBQNUXS-H4XDJ3E-RBHJPT5-45WDJJA-2U43M4P-23XGUJ7-E3CNNKZ-BXSGIA3";}; # iPhone 12 Pro Max
"lavaridge" = {id = "TMMSCVA-MDJTDPC-PC47NUA-2VPLAIB-6S6MEU7-KALIGUJ-AWDUOUU-XD73MAY";}; # Framework 13 AMD "lavaridge" = {id = "TMMSCVA-MDJTDPC-PC47NUA-2VPLAIB-6S6MEU7-KALIGUJ-AWDUOUU-XD73MAY";}; # Framework 13 AMD
"mauville" = {id = "52MTCMC-PKEWSAU-HADMTZU-DY5EKFO-B323P7V-OBXLNTQ-EJY7F7Y-EUWFBQX";}; # Desktop/Homelab "mauville" = {id = "52MTCMC-PKEWSAU-HADMTZU-DY5EKFO-B323P7V-OBXLNTQ-EJY7F7Y-EUWFBQX";}; # Desktop/Homelab
"mossdeep" = {id = "XRIGHMT-54OGBWP-UAAGAJS-LGTRHA2-EMKOMEB-EJEWKZN-GJFK6FO-3O6KQQ4";}; # Steam Deck OLED "mossdeep" = {id = "XRIGHMT-54OGBWP-UAAGAJS-LGTRHA2-EMKOMEB-EJEWKZN-GJFK6FO-3O6KQQ4";}; # Steam Deck OLED
"petalburg" = {id = "ECTD3LW-YZTJIXX-HLQYXT7-UGZSGST-3DDKF72-DJPMDHE-SUYDWIT-ASTKTAE";}; # Yoga 9i "petalburg" = {id = "ECTD3LW-YZTJIXX-HLQYXT7-UGZSGST-3DDKF72-DJPMDHE-SUYDWIT-ASTKTAE";}; # Yoga 9i
"rustboro" = {id = "7CXGPQN-7DYDYJN-DKELOR3-RD4HZUW-SSUDGLZ-WVXYFUT-DPT2MGD-6PO5BQF";}; # Thinkpad t440p "rustboro" = {id = "7CXGPQN-7DYDYJN-DKELOR3-RD4HZUW-SSUDGLZ-WVXYFUT-DPT2MGD-6PO5BQF";}; # Thinkpad t440p
"wallace" = {id = "X55NQL2-H3TEJ5U-EXZPBKQ-LI6BMB4-W2ULDIJ-YNIHJHB-4ISCOJB-UHNLYAX";}; # Samsung a35 "wallace" = {id = "X55NQL2-H3TEJ5U-EXZPBKQ-LI6BMB4-W2ULDIJ-YNIHJHB-4ISCOJB-UHNLYAX";}; # Samsung a35
"winona" = {id = "IGAW5SS-WY2QN6J-5TF74YZ-6XPNPTC-RCH3HIT-ZZQKCAI-6L54IS2-SNRIMA2";}; # Pixel Tablet "winona" = {id = "IGAW5SS-WY2QN6J-5TF74YZ-6XPNPTC-RCH3HIT-ZZQKCAI-6L54IS2-SNRIMA2";}; # Pixel Tablet
}; };
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";
params = { params = {
cleanInterval = "3600"; cleanInterval = "3600";
maxAge = "1"; maxAge = "1";
};
}; };
}; };
}; "camera" = {
"camera" = { id = "fcsgh-dlxys";
id = "fcsgh-dlxys"; path = "/home/${cfg.user}/pics/camera";
path = "/home/${config.ar.services.syncthing.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"; type = "trashcan";
type = "trashcan"; };
}; };
}; "screenshots" = {
"screenshots" = { id = "screenshots";
id = "screenshots"; path = "/home/${cfg.user}/pics/screenshots";
path = "/home/${config.ar.services.syncthing.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"; type = "trashcan";
type = "trashcan"; };
}; };
}; };
}; };
}; };
}; };
};
} }