1
0
Fork 0

WIP: Split Syncthing out into separate module

This commit is contained in:
Aires 2024-06-30 18:43:57 -04:00
parent f7c39c91ba
commit 52be766f61
2 changed files with 47 additions and 23 deletions

View file

@ -139,30 +139,16 @@ with lib;
# Enable Syncthing
(mkIf cfg.services.syncthing.enable {
users.users.aires.packages = [
pkgs.syncthing
(mkIf cfg.services.syncthing.enableTray pkgs.syncthingtray)
imports = [
(import ../common/home-manager/syncthing.nix {
username = users.users.aires.name;
configDir = "${config.users.users.aires.home}/.config/syncthing";
port = 8080;
autostart = cfg.services.syncthing.autostart;
enableTray = cfg.services.syncthing.autostart;
inherit lib pkgs;
})
];
# Open port 8080
networking.firewall.allowedTCPPorts = [ 8080 ];
home-manager.users.aires = {
# Syncthing options
services.syncthing = {
enable = true;
extraOptions = [
"--gui-address=0.0.0.0:8080"
"--home=${config.users.users.aires.home}/.config/syncthing"
"--no-default-folder"
];
};
# Override the default Syncthing settings so it doesn't start on boot
systemd.user.services."syncthing" = mkIf (!cfg.services.syncthing.autostart) {
Install = lib.mkForce { };
};
};
})
]);
}

View file

@ -0,0 +1,38 @@
{
username,
configDir,
port ? 8080,
autostart ? false,
enableTray ? false,
lib,
pkgs,
config,
...
}:
{
config = {
users.users.${username}.packages = [
pkgs.syncthing
(lib.mkIf enableTray pkgs.syncthingtray)
];
# Open port 8080
networking.firewall.allowedTCPPorts = [ port ];
home-manager.users.${username} = {
# Syncthing options
services.syncthing = {
enable = true;
extraOptions = [
"--gui-address=0.0.0.0:${port}"
"--home=${configDir}/.config/syncthing"
"--no-default-folder"
];
};
# Override the default Syncthing settings so it doesn't start on boot
systemd.user.services."syncthing" = lib.mkIf (!autostart) { Install = lib.mkForce { }; };
};
};
}