Services: move Syncthing out of home-manager
This commit is contained in:
parent
143302674d
commit
38e8576bb9
|
@ -219,6 +219,15 @@ in
|
|||
enable = true;
|
||||
ports = [ config.secrets.hosts.hevana.ssh.port ];
|
||||
};
|
||||
syncthing = {
|
||||
enable = true;
|
||||
home = "${services-root}/syncthing/aires";
|
||||
user = "aires";
|
||||
web = {
|
||||
enable = true;
|
||||
public = true;
|
||||
};
|
||||
};
|
||||
virtualization.host = {
|
||||
enable = true;
|
||||
user = "aires";
|
||||
|
@ -230,18 +239,6 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
users.aires = {
|
||||
enable = true;
|
||||
services = {
|
||||
syncthing = {
|
||||
enable = true;
|
||||
home = "${services-root}/syncthing/aires";
|
||||
web = {
|
||||
enable = true;
|
||||
public = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
users.aires.enable = true;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -55,6 +55,12 @@ in
|
|||
onCalendar = "weekly";
|
||||
user = config.users.users.aires.name;
|
||||
};
|
||||
syncthing = {
|
||||
enable = true;
|
||||
home = "/home/aires/.config/syncthing";
|
||||
user = "aires";
|
||||
web.enable = true;
|
||||
};
|
||||
virtualization.enable = true;
|
||||
};
|
||||
|
||||
|
@ -78,12 +84,6 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
users.aires = {
|
||||
enable = true;
|
||||
services.syncthing = {
|
||||
enable = true;
|
||||
web.enable = true;
|
||||
};
|
||||
};
|
||||
users.aires.enable = true;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -69,6 +69,12 @@ in
|
|||
url = config.secrets.services.netdata.url;
|
||||
auth.apiKey = config.secrets.services.netdata.apiKey;
|
||||
};
|
||||
syncthing = {
|
||||
enable = true;
|
||||
home = "/home/aires/.config/syncthing";
|
||||
user = "aires";
|
||||
web.enable = true;
|
||||
};
|
||||
# Install virtual machine management tools
|
||||
virtualization = {
|
||||
enable = true;
|
||||
|
@ -101,13 +107,7 @@ in
|
|||
desktops.gnome.enable = true;
|
||||
};
|
||||
users = {
|
||||
aires = {
|
||||
enable = true;
|
||||
services.syncthing = {
|
||||
enable = true;
|
||||
web.enable = true;
|
||||
};
|
||||
};
|
||||
aires.enable = true;
|
||||
gremlin.enable = true;
|
||||
};
|
||||
};
|
||||
|
|
54
modules/services/syncthing.nix
Normal file
54
modules/services/syncthing.nix
Normal file
|
@ -0,0 +1,54 @@
|
|||
# See https://wiki.nixos.org/wiki/Syncthing
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.aux.system.services.syncthing;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
aux.system.services.syncthing = {
|
||||
enable = lib.mkEnableOption "Enables Syncthing";
|
||||
home = lib.mkOption {
|
||||
default = "/var/lib/syncthing";
|
||||
type = lib.types.str;
|
||||
description = "Where to store Syncthing's configuration files";
|
||||
};
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "syncthing";
|
||||
description = "User account under which Syncthing runs.";
|
||||
};
|
||||
web = {
|
||||
enable = lib.mkEnableOption "Enables the Syncthing web UI.";
|
||||
port = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 8384;
|
||||
description = "The port to host Syncthing web on.";
|
||||
};
|
||||
public = lib.mkEnableOption "Whether to expose the Syncthing web UI to the network.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# If the web UI is public, open the port in the firewall
|
||||
networking.firewall.allowedTCPPorts = with cfg.web; lib.mkIf (enable && public) [ port ];
|
||||
|
||||
services.syncthing = {
|
||||
enable = true;
|
||||
user = cfg.user;
|
||||
group = config.users.users.${cfg.user}.group;
|
||||
configDir = cfg.home;
|
||||
guiAddress =
|
||||
let
|
||||
listenAddress = with cfg.web; (if (enable && public) then "0.0.0.0" else "127.0.0.1");
|
||||
in
|
||||
"${listenAddress}:${builtins.toString cfg.web.port}";
|
||||
};
|
||||
|
||||
systemd.services.syncthing = {
|
||||
environment.STNODEFAULTFOLDER = "true"; # Don't create default ~/Sync folder
|
||||
unitConfig.RequiresMountsFor = cfg.home;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
|
@ -14,25 +13,6 @@ in
|
|||
aux.system.users.aires = {
|
||||
enable = lib.mkEnableOption "Enables aires user account";
|
||||
autologin = lib.mkEnableOption "Automatically logs aires in on boot";
|
||||
|
||||
services.syncthing = {
|
||||
enable = lib.mkEnableOption "Enables Syncthing";
|
||||
enableTray = lib.mkEnableOption "Enables the Syncthing Tray application";
|
||||
home = lib.mkOption {
|
||||
default = "${config.users.users.aires.home}/.config/syncthing";
|
||||
type = lib.types.str;
|
||||
description = "Where to store Syncthing's configuration files";
|
||||
};
|
||||
web = {
|
||||
enable = lib.mkEnableOption "Enables the Syncthing web UI.";
|
||||
port = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 8384;
|
||||
description = "The port to host Syncthing web on.";
|
||||
};
|
||||
public = lib.mkEnableOption "Whether to expose the Syncthing web UI to the network.";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -129,39 +109,6 @@ in
|
|||
"autovt@tty1".enable = false;
|
||||
};
|
||||
})
|
||||
|
||||
# Configure Syncthing
|
||||
(lib.mkIf cfg.services.syncthing.enable {
|
||||
users.users.aires.packages = [ pkgs.syncthing ];
|
||||
|
||||
services.flatpak.packages = lib.mkIf (
|
||||
config.aux.system.ui.flatpak.enable && cfg.services.syncthing.enableTray
|
||||
) [ "io.github.martchus.syncthingtray" ];
|
||||
|
||||
# If the web UI is public, open the port in the firewall
|
||||
networking.firewall.allowedTCPPorts =
|
||||
with cfg.services.syncthing.web;
|
||||
lib.mkIf (enable && public) [ port ];
|
||||
|
||||
home-manager.users.aires = {
|
||||
services.syncthing = {
|
||||
enable = true;
|
||||
extraOptions =
|
||||
let
|
||||
listenAddress =
|
||||
with cfg.services.syncthing.web;
|
||||
(if (enable && public) then "0.0.0.0" else "127.0.0.1");
|
||||
in
|
||||
[
|
||||
"--gui-address=${listenAddress}:${builtins.toString cfg.services.syncthing.web.port}"
|
||||
"--home=${cfg.services.syncthing.home}"
|
||||
"--no-default-folder"
|
||||
];
|
||||
};
|
||||
|
||||
systemd.user.services."syncthing".Unit.RequiresMountsFor = cfg.services.syncthing.home;
|
||||
};
|
||||
})
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue