36 lines
898 B
Nix
36 lines
898 B
Nix
{ pkgs, config, lib, ... }:
|
|
|
|
let
|
|
cfg = config.modules.system.syncthing;
|
|
in
|
|
{
|
|
options.modules.system.syncthing = {
|
|
enable = lib.mkEnableOption "enables syncthing";
|
|
|
|
mode = lib.mkOption {
|
|
type = lib.types.enum [ "server" "client" ];
|
|
default = "client";
|
|
description = "whether syncthing should run as a client (user) or server (system-wide).";
|
|
};
|
|
|
|
data_dir = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = if cfg.mode == "server"
|
|
then "/var/lib/syncthing"
|
|
else "/home/blake/.local/state/syncthing";
|
|
description = "optional override for syncthing data directory.";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
services.syncthing = {
|
|
enable = true;
|
|
user = "blake";
|
|
group = "blake";
|
|
dataDir = cfg.data_dir;
|
|
guiAddress = "0.0.0.0:2222";
|
|
openDefaultPorts = true;
|
|
};
|
|
};
|
|
}
|