WIP: Split Syncthing out into separate module
This commit is contained in:
parent
f7c39c91ba
commit
52be766f61
|
@ -139,30 +139,16 @@ with lib;
|
||||||
|
|
||||||
# Enable Syncthing
|
# Enable Syncthing
|
||||||
(mkIf cfg.services.syncthing.enable {
|
(mkIf cfg.services.syncthing.enable {
|
||||||
users.users.aires.packages = [
|
imports = [
|
||||||
pkgs.syncthing
|
(import ../common/home-manager/syncthing.nix {
|
||||||
(mkIf cfg.services.syncthing.enableTray pkgs.syncthingtray)
|
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 { };
|
|
||||||
};
|
|
||||||
};
|
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
38
modules/users/common/home-manager/syncthing.nix
Normal file
38
modules/users/common/home-manager/syncthing.nix
Normal 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 { }; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue