nix-configs/modules/user-services/syncthing.nix

28 lines
777 B
Nix

{
pkgs,
config,
lib,
...
}:
let
cfg = config.xyno.user-services.syncthing;
in
{
options.xyno.user-services.syncthing.enable = lib.mkEnableOption "enable syncthing as user/with gui";
options.xyno.user-services.syncthing.wantedBy = lib.mkOption {
type = lib.types.str;
default = "niri.service";
};
options.xyno.user-services.syncthing.tray = lib.mkEnableOption "add syncthingtray";
config = lib.mkIf cfg.enable {
services.syncthing = {
systemService = false;
enable = true;
openDefaultPorts = true;
};
environment.systemPackages = lib.optionals cfg.tray [ pkgs.syncthingtray ];
systemd.packages = lib.optionals cfg.tray [ pkgs.syncthingtray ];
systemd.user.services.syncthing.wantedBy = [ cfg.wantedBy ];
};
}