1
0
Fork 0

Services: tweak and cleanup Syncthing config

This commit is contained in:
Aires 2024-11-17 12:00:33 -05:00
parent 51b5d481c8
commit 1d4f4ead54
5 changed files with 43 additions and 50 deletions

View file

@ -229,6 +229,11 @@ in
syncthing = { syncthing = {
enable = true; enable = true;
home = "${services-root}/syncthing/aires"; home = "${services-root}/syncthing/aires";
web = {
enable = true;
port = 8080;
public = true;
};
}; };
}; };
}; };

View file

@ -83,7 +83,14 @@ in
users.aires = { users.aires = {
enable = true; enable = true;
services.syncthing.enable = true; services.syncthing = {
enable = true;
enableTray = true;
web = {
enable = true;
port = 8080;
};
};
}; };
}; };
} }

View file

@ -108,15 +108,13 @@ in
services.syncthing = { services.syncthing = {
enable = true; enable = true;
enableTray = true; enableTray = true;
web = {
enable = true;
port = 8080;
};
}; };
}; };
gremlin = { gremlin.enable = true;
enable = true;
services.syncthing = {
enable = true;
enableTray = true;
};
};
}; };
}; };

View file

@ -23,6 +23,15 @@ in
type = lib.types.str; type = lib.types.str;
description = "Where to store Syncthing's configuration files"; 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.";
};
}; };
}; };
}; };
@ -120,7 +129,7 @@ in
}; };
}) })
# Enable Syncthing # Configure Syncthing
(lib.mkIf cfg.services.syncthing.enable { (lib.mkIf cfg.services.syncthing.enable {
users.users.aires.packages = [ pkgs.syncthing ]; users.users.aires.packages = [ pkgs.syncthing ];
@ -128,18 +137,25 @@ in
config.aux.system.ui.flatpak.enable && cfg.services.syncthing.enableTray config.aux.system.ui.flatpak.enable && cfg.services.syncthing.enableTray
) [ "io.github.martchus.syncthingtray" ]; ) [ "io.github.martchus.syncthingtray" ];
# Open port 8080 # If the web UI is public, open the port in the firewall
networking.firewall.allowedTCPPorts = [ 8080 ]; networking.firewall.allowedTCPPorts =
with cfg.services.syncthing.web;
lib.mkIf (enable && public) [ port ];
home-manager.users.aires = { home-manager.users.aires = {
# Syncthing options
services.syncthing = { services.syncthing = {
enable = true; enable = true;
extraOptions = [ extraOptions =
"--gui-address=0.0.0.0:8080" let
"--home=${cfg.services.syncthing.home}" listenAddress =
"--no-default-folder" 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; systemd.user.services."syncthing".Unit.RequiresMountsFor = cfg.services.syncthing.home;

View file

@ -13,16 +13,6 @@ in
options = { options = {
aux.system.users.gremlin = { aux.system.users.gremlin = {
enable = lib.mkEnableOption "Enables gremlin user account"; enable = lib.mkEnableOption "Enables gremlin user account";
services.syncthing = {
enable = lib.mkEnableOption "Enables Syncthing";
enableTray = lib.mkEnableOption "Enables the Syncthing Tray application";
home = lib.mkOption {
default = "${config.users.users.gremlin.home}/.config/syncthing";
type = lib.types.str;
description = "Where to store Syncthing's configuration files";
};
};
}; };
}; };
@ -100,28 +90,5 @@ in
}; };
}; };
}) })
# Enable Syncthing
(lib.mkIf cfg.services.syncthing.enable {
users.users.gremlin.packages = [ pkgs.syncthing ];
services.flatpak.packages = lib.mkIf (
config.aux.system.ui.flatpak.enable && cfg.services.syncthing.enableTray
) [ "io.github.martchus.syncthingtray" ];
home-manager.users.gremlin = {
# Syncthing options
services.syncthing = {
enable = true;
extraOptions = [
"--gui-address=0.0.0.0:8081"
"--home=${cfg.services.syncthing.home}"
"--no-default-folder"
];
};
systemd.user.services."syncthing".Unit.RequiresMountsFor = cfg.services.syncthing.home;
};
})
]; ];
} }