adopted new syncthing flake

This commit is contained in:
Leyla Becker 2025-03-13 02:13:11 -05:00
parent 80092713e3
commit 395a25eff1
5 changed files with 154 additions and 93 deletions

View file

@ -1,6 +1,7 @@
{
config,
lib,
outputs,
...
}: let
mountDir = "/mnt/sync";
@ -59,97 +60,24 @@ in {
configDir = configDir;
overrideDevices = true;
overrideFolders = true;
settings = {
devices = {
ceder = {
id = "MGXUJBS-7AENXHB-7YQRNWG-QILKEJD-5462U2E-WAQW4R4-I2TVK5H-SMK6LAA";
};
coven = {
id = "QGU7NN6-OMXTWVA-YCZ73S5-2O7ECTS-MUCTN4M-YH6WLEL-U4U577I-7PBNCA5";
};
defiant = lib.mkIf (config.networking.hostName != "defiant") {
id = "3R6E6Y4-2F7MF2I-IGB4WE6-A3SQSMV-LIBYSAM-2OXHHU2-KJ6CGIV-QNMCPAR";
};
twilight = lib.mkIf (config.networking.hostName != "twilight") {
id = "UDIYL7V-OAZ2BI3-EJRAWFB-GZYVDWR-JNUYW3F-FFQ35MU-XBTGWEF-QD6K6QN";
};
horizon = lib.mkIf (config.networking.hostName != "horizon") {
id = "OGPAEU6-5UR56VL-SP7YC4Y-IMVCRTO-XFD4CYN-Z6T5TZO-PFZNAT6-4MKWPQS";
};
shale = {
id = "AOAXEVD-QJ2IVRA-6G44Q7Q-TGUPXU2-FWWKOBH-DPKWC5N-LBAEHWJ-7EQF4AM";
};
};
folders = let
ceder = "ceder";
coven = "coven";
shale = "shale";
defiant = lib.mkIf (config.networking.hostName != "defiant") "defiant";
twilight = lib.mkIf (config.networking.hostName != "twilight") "twilight";
horizon = lib.mkIf (config.networking.hostName != "horizon") "horizon";
in
lib.mkMerge [
config.host.sync.folders.extraFolders
(lib.mkIf config.host.sync.folders.leyla.documents.enable {
"documents" = {
id = "hvrj0-9bm1p";
path = "${mountDir}/leyla/documents";
devices = [
defiant
ceder
coven
twilight
horizon
];
};
})
(lib.mkIf config.host.sync.folders.share.calendar.enable {
"calendar" = {
id = "8oatl-1rv6w";
path = "${mountDir}/default/calendar";
devices = [
defiant
ceder
shale
];
};
})
(lib.mkIf config.host.sync.folders.leyla.notes.enable {
"notes" = {
id = "dwbuv-zffnf";
path = "${mountDir}/leyla/notes";
devices = [
defiant
ceder
];
};
})
(lib.mkIf config.host.sync.folders.share.enable {
"share" = {
id = "73ot0-cxmkx";
path = "${mountDir}/default/share";
devices = [
defiant
ceder
coven
twilight
horizon
shale
];
};
})
];
};
configuration = outputs.syncthingConfiguration;
deviceName = config.networking.hostName;
};
}
(lib.mkIf config.host.impermanence.enable {
assertions = [
{
assertion = config.services.syncthing.configDir == configDir;
message = "syncthing config dir does not match persistence";
}
];
assertions =
[
{
assertion = config.services.syncthing.configDir == configDir;
message = "syncthing config dir does not match persistence";
}
]
++ lib.attrsets.mapAttrsToList (_: folder: {
assertion = lib.strings.hasPrefix mountDir folder.path;
message = "syncthing folder ${folder.label} is stored at ${folder.path} which not under the persisted path of ${mountDir}";
})
config.services.syncthing.folders;
environment.persistence = {
"/persist/system/root" = {
enable = true;