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/immich | |
parent | bc7b54af5193f8ac7333ce3f27f414f9a69a80c0 (diff) |
services: major overhaul on service modules
Diffstat (limited to 'modules/services/immich')
-rw-r--r-- | modules/services/immich/default.nix | 63 |
1 files changed, 50 insertions, 13 deletions
diff --git a/modules/services/immich/default.nix b/modules/services/immich/default.nix index 7904423..95da536 100644 --- a/modules/services/immich/default.nix +++ b/modules/services/immich/default.nix @@ -1,18 +1,55 @@ -{ pkgs, ... }: { - services.immich = { - enable = true; - package = pkgs.immich; - host = "localhost"; - port = 2283; - mediaLocation = "/tank/immich"; - environment = { - IMMICH_LOG_LEVEL = "log"; + config, + lib, + pkgs, + ... +}: +with lib; +let + cfg = config.modules.services.immich; +in +{ + options.modules.services.immich = { + enable = mkEnableOption "immich"; + port = mkOption { + default = 2283; + type = types.int; + }; + url = mkOption { + default = null; + type = types.str; + }; + mediaDir = mkOption { + default = "/var/lib/immich"; + type = types.str; }; }; - services.caddy.virtualHosts."photographs.brownbread.net".extraConfig = '' - encode zstd gzip - reverse_proxy http://localhost:2283 - ''; + config = mkIf cfg.enable { + networking.firewall.allowedTCPPorts = mkIf (cfg.url != null) [ + 80 + 443 + ]; + + services.caddy = mkIf (cfg.url != null) { + enable = true; + virtualHosts = { + "photographs.brownbread.net".extraConfig = '' + encode zstd gzip + reverse_proxy http://localhost:${builtins.toString cfg.port} + ''; + }; + }; + + services.immich = { + enable = true; + package = pkgs.immich; + host = "localhost"; + port = cfg.port; + mediaLocation = cfg.mediaDir; + environment = { + IMMICH_LOG_LEVEL = "log"; + }; + }; + }; } |