feat(syncthing): set up LAN-only sync for 'readings'
This commit is contained in:
@@ -67,7 +67,16 @@ in
|
||||
};
|
||||
ssh.enable = true;
|
||||
storage.enable = true;
|
||||
syncthing.enable = true;
|
||||
syncthing = {
|
||||
enable = true;
|
||||
folders.readings = {
|
||||
path = "/home/${config.host.username}/doc/readings";
|
||||
devices = [
|
||||
"astyanax"
|
||||
"boox"
|
||||
];
|
||||
};
|
||||
};
|
||||
tailscale.enable = true;
|
||||
taskwarrior.enable = true;
|
||||
wol = {
|
||||
|
||||
@@ -49,6 +49,16 @@ in
|
||||
secrets.enable = true;
|
||||
ssh.enable = true;
|
||||
storage.enable = true;
|
||||
syncthing = {
|
||||
enable = true;
|
||||
folders.readings = {
|
||||
path = "/home/${config.host.username}/doc/readings";
|
||||
devices = [
|
||||
"andromache"
|
||||
"boox"
|
||||
];
|
||||
};
|
||||
};
|
||||
taskwarrior.enable = true;
|
||||
|
||||
secrets.nixSigningKey.enable = true;
|
||||
|
||||
@@ -3,9 +3,42 @@
|
||||
let
|
||||
cfg = config.syncthing;
|
||||
inherit (config.host) username;
|
||||
|
||||
deviceRegistry = import ./devices.nix;
|
||||
deviceName = lib.types.enum (builtins.attrNames deviceRegistry);
|
||||
referencedDevices = lib.unique (
|
||||
lib.concatMap (folder: folder.devices) (lib.attrValues cfg.folders)
|
||||
);
|
||||
in
|
||||
{
|
||||
options.syncthing.enable = lib.mkEnableOption "syncthing";
|
||||
options.syncthing = {
|
||||
enable = lib.mkEnableOption "syncthing";
|
||||
folders = lib.mkOption {
|
||||
default = { };
|
||||
type = lib.types.attrsOf (
|
||||
lib.types.submodule {
|
||||
options = {
|
||||
path = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
type = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"sendreceive"
|
||||
"sendonly"
|
||||
"receiveonly"
|
||||
"receiveencrypted"
|
||||
];
|
||||
default = "sendreceive";
|
||||
};
|
||||
devices = lib.mkOption {
|
||||
type = lib.types.listOf deviceName;
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.groups.${username} = { };
|
||||
@@ -17,6 +50,21 @@ in
|
||||
group = username;
|
||||
configDir = "/home/${username}/.local/state/syncthing";
|
||||
openDefaultPorts = true;
|
||||
settings = {
|
||||
devices = lib.getAttrs referencedDevices deviceRegistry;
|
||||
folders = lib.mapAttrs (_: folder: {
|
||||
inherit (folder)
|
||||
path
|
||||
type
|
||||
devices
|
||||
;
|
||||
}) cfg.folders;
|
||||
options = {
|
||||
globalAnnounceEnabled = false;
|
||||
localAnnounceEnabled = true;
|
||||
relaysEnabled = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user