mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-12-14 02:20:53 -06:00
123 lines
3 KiB
Nix
Executable file
123 lines
3 KiB
Nix
Executable file
{ flake, nasHelpers, ... }:
|
|
let
|
|
inherit (import ./config { inherit flake; }) syncthingVM;
|
|
inherit (flake.config.services) instances;
|
|
inherit (flake.config.people) user0;
|
|
inherit (nasHelpers)
|
|
ipAddress
|
|
guestPath
|
|
docsPath
|
|
mediaPath
|
|
miscPath
|
|
syncthing
|
|
;
|
|
serviceCfg = instances.syncthing;
|
|
id0 = builtins.toString syncthing.id0;
|
|
id1 = builtins.toString syncthing.id1;
|
|
id2 = builtins.toString syncthing.id2;
|
|
|
|
foldersHelper = user: {
|
|
docs = {
|
|
enable = true;
|
|
id = "docs";
|
|
path = "/var/lib/${serviceCfg.name}/docs";
|
|
devices = [
|
|
"${user}Phone"
|
|
];
|
|
};
|
|
media = {
|
|
enable = true;
|
|
id = "media";
|
|
path = "/var/lib/${serviceCfg.name}/media";
|
|
devices = [
|
|
"${user}Phone"
|
|
];
|
|
};
|
|
misc = {
|
|
enable = true;
|
|
id = "misc";
|
|
path = "/var/lib/${serviceCfg.name}/misc";
|
|
devices = [
|
|
"${user}Phone"
|
|
];
|
|
};
|
|
};
|
|
|
|
devicesHelper = user: syncID: device: deviceIP: {
|
|
"${user}${device}" = {
|
|
autoAcceptFolders = true;
|
|
name = "${user}${device}";
|
|
addresses = [
|
|
"tcp://${deviceIP}:${toString serviceCfg.ports.port2}"
|
|
];
|
|
id = syncID;
|
|
};
|
|
};
|
|
|
|
mountsHelper = user: [
|
|
{
|
|
mountPoint = "/var/lib/${serviceCfg.name}/docs";
|
|
proto = "virtiofs";
|
|
source = docsPath user;
|
|
tag = "${serviceCfg.name}_${user}_docs";
|
|
}
|
|
{
|
|
mountPoint = "/var/lib/${serviceCfg.name}/media";
|
|
proto = "virtiofs";
|
|
source = mediaPath user;
|
|
tag = "${serviceCfg.name}_${user}_media";
|
|
}
|
|
{
|
|
mountPoint = "/var/lib/${serviceCfg.name}/misc";
|
|
proto = "virtiofs";
|
|
source = miscPath user;
|
|
tag = "${serviceCfg.name}_${user}_misc";
|
|
}
|
|
];
|
|
|
|
tmpRules = [
|
|
"d /var/lib/${serviceCfg.name}/docs 0755 ${serviceCfg.name} ${serviceCfg.name} -"
|
|
"d /var/lib/${serviceCfg.name}/media 0755 ${serviceCfg.name} ${serviceCfg.name} -"
|
|
"d /var/lib/${serviceCfg.name}/misc 0755 ${serviceCfg.name} ${serviceCfg.name} -"
|
|
];
|
|
|
|
syncthingNick =
|
|
let
|
|
phoneID = "OALKHLZ-OODUWVX-PAC2LI7-UMZMSZO-FELLRCD-RS4DHJS-PVA5YQK-WTFXXQI";
|
|
in
|
|
syncthingVM {
|
|
user = user0;
|
|
ip = ipAddress id0;
|
|
mac = "02:00:00:00:${id0}:${id0}";
|
|
userMac = "02:00:00:00:00:${id0}";
|
|
ssh = syncthing.ssh0;
|
|
mnt = guestPath user0;
|
|
folders = foldersHelper user0;
|
|
devices = devicesHelper user0 phoneID "Phone" "192.168.50.8";
|
|
tmp = tmpRules;
|
|
mounts = mountsHelper user0;
|
|
};
|
|
|
|
# syncthingStacie = syncthingVM {
|
|
# user = "stacie";
|
|
# ip = ipAddress id0;
|
|
# mac = "02:00:00:00:${id0}:${id0}";
|
|
# userMac = "02:00:00:00:00:${id0}";
|
|
# ssh = syncthing.ssh0;
|
|
# syncID = "";
|
|
# deviceIP = "";
|
|
# };
|
|
|
|
# syncthingGarnet = syncthingVM {
|
|
# user = "garnet";
|
|
# ip = ipAddress id0;
|
|
# mac = "02:00:00:00:${id0}:${id0}";
|
|
# userMac = "02:00:00:00:00:${id0}";
|
|
# ssh = syncthing.ssh0;
|
|
# syncID = "";
|
|
# deviceIP = "";
|
|
# };
|
|
|
|
in
|
|
syncthingNick
|
|
# // syncthingStacie // syncthingGarnet
|