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 = {
"desktop" = { id = "767Z675-SOCY4FL-JNYEBB6-5E2RG5O-XTZR6OP-BGOBZ7G-XVRLMD6-DQEB2AT"; };
"home" = { id = "L5A5IPE-2FPJPHP-RJRV2PV-BLMLC3F-QPHSCUQ-4U3NM2I-AFPOE2A-HOPQZQF"; };
"phone" = { id = "6RO5JXW-2XO4S3E-VCDAHPD-4ADK6LL-HQGMZHU-GD6DE2O-6KNHWXJ-BCSBGQ7"; };
}; };
settings = lib.mkOption { folders = let
default = { }; everyone = lib.mapAttrsToList (n: v: n) config.services.syncthing.settings.devices;
type = lib.types.attrs; in {
"save" = {
path = "${cfg.dataDir}/save";
devices = [
"desktop"
"home"
# "work"
];
};
"photo" = {
path = "${cfg.dataDir}/photo";
devices = [
"home"
"phone"
];
};
"tmp" = {
path = "${cfg.dataDir}/tmp";
devices = everyone;
};
"document" = {
path = "${cfg.dataDir}/document";
devices = everyone;
}; };
user = lib.mkOption {
default = "voronind";
type = lib.types.str;
}; };
group = lib.mkOption {
default = "users";
type = lib.types.str;
}; };
openDefaultPorts = lib.mkOption {
default = true;
type = lib.types.bool;
}; };
}; };
} }

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"; };
"home" = { id = "L5A5IPE-2FPJPHP-RJRV2PV-BLMLC3F-QPHSCUQ-4U3NM2I-AFPOE2A-HOPQZQF"; };
"phone" = { id = "6RO5JXW-2XO4S3E-VCDAHPD-4ADK6LL-HQGMZHU-GD6DE2O-6KNHWXJ-BCSBGQ7"; };
}; };
folders = { settings = lib.mkOption {
"save" = { default = { };
path = "${cfg.dataDir}/save"; type = lib.types.attrs;
devices = [
"desktop"
"home"
# "work"
];
}; };
"photo" = { user = lib.mkOption {
path = "${cfg.dataDir}/photo"; default = "voronind";
devices = [ type = lib.types.str;
"home"
"phone"
];
}; };
"tmp" = { group = lib.mkOption {
path = "${cfg.dataDir}/tmp"; default = "users";
devices = [ type = lib.types.str;
"desktop"
"home"
"phone"
];
}; };
}; openDefaultPorts = lib.mkOption {
} cfg.settings; default = true;
type = lib.types.bool;
}; };
}; };
} }