Syncthing: Add document dir.

This commit is contained in:
Dmitry Voronin 2024-12-08 07:17:06 +03:00
parent 361b6742a8
commit 80d544b9ed
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
2 changed files with 62 additions and 60 deletions

View file

@ -1,32 +1,50 @@
{ {
config, config,
lib, lib,
pkgs,
... ...
}: let }: let
cfg = config.module.syncthing; cfg = config.module.syncthing;
in { in {
# NOTE: Access at `http://localhost:8384`. config = lib.mkIf cfg.enable {
options.module.syncthing = { environment.systemPackages = with pkgs; [ syncthing ];
enable = lib.mkEnableOption "the file sync."; services.syncthing = {
dataDir = lib.mkOption { inherit (cfg) enable dataDir user group openDefaultPorts;
default = "/home/${cfg.user}/sync"; systemService = true;
type = lib.types.str; settings = lib.recursiveUpdate cfg.settings {
}; devices = {
settings = lib.mkOption { "desktop" = { id = "767Z675-SOCY4FL-JNYEBB6-5E2RG5O-XTZR6OP-BGOBZ7G-XVRLMD6-DQEB2AT"; };
default = { }; "home" = { id = "L5A5IPE-2FPJPHP-RJRV2PV-BLMLC3F-QPHSCUQ-4U3NM2I-AFPOE2A-HOPQZQF"; };
type = lib.types.attrs; "phone" = { id = "6RO5JXW-2XO4S3E-VCDAHPD-4ADK6LL-HQGMZHU-GD6DE2O-6KNHWXJ-BCSBGQ7"; };
}; };
user = lib.mkOption { folders = let
default = "voronind"; everyone = lib.mapAttrsToList (n: v: n) config.services.syncthing.settings.devices;
type = lib.types.str; in {
}; "save" = {
group = lib.mkOption { path = "${cfg.dataDir}/save";
default = "users"; devices = [
type = lib.types.str; "desktop"
}; "home"
openDefaultPorts = lib.mkOption { # "work"
default = true; ];
type = lib.types.bool; };
"photo" = {
path = "${cfg.dataDir}/photo";
devices = [
"home"
"phone"
];
};
"tmp" = {
path = "${cfg.dataDir}/tmp";
devices = everyone;
};
"document" = {
path = "${cfg.dataDir}/document";
devices = everyone;
};
};
};
}; };
}; };
} }

View file

@ -1,48 +1,32 @@
{ {
config, config,
lib, lib,
pkgs,
... ...
}: let }: let
cfg = config.module.syncthing; cfg = config.module.syncthing;
in { in {
config = lib.mkIf cfg.enable { # NOTE: Access at `http://localhost:8384`.
environment.systemPackages = with pkgs; [ syncthing ]; options.module.syncthing = {
services.syncthing = { enable = lib.mkEnableOption "the file sync.";
inherit (cfg) enable dataDir user group openDefaultPorts; dataDir = lib.mkOption {
systemService = true; default = "/home/${cfg.user}/sync";
settings = lib.recursiveUpdate { type = lib.types.str;
devices = { };
"desktop" = { id = "767Z675-SOCY4FL-JNYEBB6-5E2RG5O-XTZR6OP-BGOBZ7G-XVRLMD6-DQEB2AT"; }; settings = lib.mkOption {
"home" = { id = "L5A5IPE-2FPJPHP-RJRV2PV-BLMLC3F-QPHSCUQ-4U3NM2I-AFPOE2A-HOPQZQF"; }; default = { };
"phone" = { id = "6RO5JXW-2XO4S3E-VCDAHPD-4ADK6LL-HQGMZHU-GD6DE2O-6KNHWXJ-BCSBGQ7"; }; type = lib.types.attrs;
}; };
folders = { user = lib.mkOption {
"save" = { default = "voronind";
path = "${cfg.dataDir}/save"; type = lib.types.str;
devices = [ };
"desktop" group = lib.mkOption {
"home" default = "users";
# "work" type = lib.types.str;
]; };
}; openDefaultPorts = lib.mkOption {
"photo" = { default = true;
path = "${cfg.dataDir}/photo"; type = lib.types.bool;
devices = [
"home"
"phone"
];
};
"tmp" = {
path = "${cfg.dataDir}/tmp";
devices = [
"desktop"
"home"
"phone"
];
};
};
} cfg.settings;
}; };
}; };
} }