diff options
author | tdback <tyler@tdback.net> | 2025-01-26 11:34:28 -0500 |
---|---|---|
committer | tdback <tyler@tdback.net> | 2025-01-26 11:34:28 -0500 |
commit | 99e940770b61db350379d692df7cf3831ef4bd92 (patch) | |
tree | d927d171b483b9ae07de4ab615f250edf25e535a /modules/services/fediverse | |
parent | bc7b54af5193f8ac7333ce3f27f414f9a69a80c0 (diff) |
services: major overhaul on service modules
Diffstat (limited to 'modules/services/fediverse')
-rw-r--r-- | modules/services/fediverse/default.nix | 67 |
1 files changed, 48 insertions, 19 deletions
diff --git a/modules/services/fediverse/default.nix b/modules/services/fediverse/default.nix index 0c3c696..b67cdcc 100644 --- a/modules/services/fediverse/default.nix +++ b/modules/services/fediverse/default.nix @@ -1,26 +1,55 @@ -{ pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: +with lib; let - domain = "social.tdback.net"; - port = 8080; + cfg = config.modules.services.fediverse; in { - services.gotosocial = { - enable = true; - package = pkgs.unstable.gotosocial; - settings = { - application-name = "gotosocial"; - host = "${domain}"; - protocol = "https"; - bind-address = "localhost"; - port = port; - db-type = "sqlite"; - db-address = "/var/lib/gotosocial/database.sqlite"; - storage-local-base-path = "/var/lib/gotosocial/storage"; + options.modules.services.fediverse = { + enable = mkEnableOption "fediverse"; + package = mkPackageOption pkgs "gotosocial" { }; + port = mkOption { + default = 8080; + type = types.int; + }; + url = mkOption { + type = types.str; }; }; - services.caddy.virtualHosts.${domain}.extraConfig = '' - encode zstd gzip - reverse_proxy http://localhost:${builtins.toString port} - ''; + config = mkIf cfg.enable { + networking.firewall.allowedTCPPorts = [ + 80 + 443 + ]; + + services.caddy = { + enable = true; + virtualHosts = { + ${cfg.url}.extraConfig = '' + encode zstd gzip + reverse_proxy http://localhost:${builtins.toString cfg.port} + ''; + }; + }; + + services.gotosocial = { + enable = true; + package = cfg.package; + settings = { + application-name = "gotosocial"; + bind-address = "localhost"; + port = cfg.port; + host = cfg.url; + protocol = "https"; + db-type = "sqlite"; + db-address = "/var/lib/gotosocial/database.sqlite"; + storage-local-base-path = "/var/lib/gotosocial/storage"; + }; + }; + }; } |