aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-06-13 15:02:58 +0530
committerAkshay Nair <phenax5@gmail.com>2025-06-13 15:02:58 +0530
commitfb3c68a676643e60e396daf4076684e12d157677 (patch)
tree16a6ee14a9d745079e99a066ad30efda1f947e72 /modules
parente6b171f9f1d975ffe34e7a34743b5e92e8593847 (diff)
downloadhomeserver-nixos-config-fb3c68a676643e60e396daf4076684e12d157677.tar.gz
homeserver-nixos-config-fb3c68a676643e60e396daf4076684e12d157677.zip
Syncthing + service router refactor
Diffstat (limited to '')
-rw-r--r--modules/hardware.nix7
-rw-r--r--modules/network/default.nix16
-rw-r--r--modules/network/service-router.service.nix (renamed from modules/service-router.service.nix)7
-rw-r--r--modules/storage/default.nix6
-rw-r--r--modules/storage/syncthing.nix44
5 files changed, 78 insertions, 2 deletions
diff --git a/modules/hardware.nix b/modules/hardware.nix
index 5a20353..7b11ca6 100644
--- a/modules/hardware.nix
+++ b/modules/hardware.nix
@@ -63,4 +63,11 @@
swapDevices = [{ device = "/dev/disk/by-label/swap"; }];
networking.useDHCP = lib.mkDefault true;
+
+ systemd.extraConfig = ''DefaultLimitNOFILE=65536'';
+ systemd.user.extraConfig = ''DefaultLimitNOFILE=65536'';
+ boot.kernel.sysctl."fs.inotify.max_user_instances" = 8192;
+ security.pam.loginLimits = [
+ { domain = "*"; type = "-"; item = "nofile"; value = "65536"; }
+ ];
}
diff --git a/modules/network/default.nix b/modules/network/default.nix
index ee3462c..6a40ef7 100644
--- a/modules/network/default.nix
+++ b/modules/network/default.nix
@@ -1,12 +1,28 @@
{ lib, ... }:
let
settings = import ../../settings.nix { inherit lib; };
+ ports = settings.network.ports;
+ host = settings.network.host;
in
{
imports = [
./ssh.nix
+ ./service-router.service.nix
];
+ services.service-router = {
+ enable = true;
+ routes = {
+ "home.local" = { inherit host; port = ports.dashboard; };
+ "sonarr.local" = { inherit host; port = ports.sonarr; };
+ "radarr.local" = { inherit host; port = ports.radarr; };
+ "prowlarr.local" = { inherit host; port = ports.prowlarr; };
+ "jellyfin.local" = { inherit host; port = ports.jellyfin; };
+ "syncthing.local" = { inherit host; port = ports.syncthing; };
+ "lidarr.local" = { inherit host; port = ports.lidarr; };
+ };
+ };
+
networking = {
hostName = "bacchus";
diff --git a/modules/service-router.service.nix b/modules/network/service-router.service.nix
index 0b9a873..9c4e6e2 100644
--- a/modules/service-router.service.nix
+++ b/modules/network/service-router.service.nix
@@ -19,6 +19,7 @@ in {
port = mkOption { type = types.int; };
host = mkOption { type = types.str; default = "127.0.0.1"; };
protocol = mkOption { type = types.str; default = "http"; };
+ nginx = mkOption { type = types.attrs; default = {}; };
}; });
default = {};
};
@@ -27,10 +28,12 @@ in {
config = lib.mkIf cfg.enable {
services.nginx = {
enable = true;
+ recommendedOptimisation = true;
virtualHosts = lib.mapAttrs (_: val: {
- locations."/" = {
+ locations."/" = if val.nginx == {} then {
proxyPass = "${val.protocol}://${val.host}:${toString val.port}";
- };
+ proxyWebsockets = true;
+ } else val.nginx;
}) cfg.routes;
};
diff --git a/modules/storage/default.nix b/modules/storage/default.nix
new file mode 100644
index 0000000..22bd2ff
--- /dev/null
+++ b/modules/storage/default.nix
@@ -0,0 +1,6 @@
+{ ... }:
+{
+ imports = [
+ ./syncthing.nix
+ ];
+}
diff --git a/modules/storage/syncthing.nix b/modules/storage/syncthing.nix
new file mode 100644
index 0000000..5291182
--- /dev/null
+++ b/modules/storage/syncthing.nix
@@ -0,0 +1,44 @@
+{ lib, ... }:
+let
+ settings = import ../../settings.nix { inherit lib; };
+ group = "syncthing";
+in
+{
+ systemd.tmpfiles.rules = [
+ "d ${settings.syncthing.baseDir} 0770 - ${group} - -"
+ "d ${settings.syncthing.photosDir} 0770 - ${group} - -"
+ ];
+ users.groups.${group} = { };
+ users.users.bacchus.extraGroups = [ group ];
+
+ networking.firewall.allowedTCPPorts = [ settings.network.ports.syncthing ];
+
+ services.syncthing = {
+ enable = true;
+ user = "bacchus";
+ group = group;
+ dataDir = settings.syncthing.baseDir;
+ guiAddress = "0.0.0.0:${toString settings.network.ports.syncthing}";
+ overrideFolders = true;
+
+ settings = {
+ folders = {
+ artemis-photos = {
+ label = "Photos";
+ path = settings.syncthing.photosDir;
+ };
+ };
+
+ options.urAccepted = -1;
+
+ extraOptions = {
+ gui = {
+ enabled = true;
+ theme = "black";
+ user = settings.syncthing.username;
+ password = settings.syncthing.password;
+ };
+ };
+ };
+ };
+}