From 9442388ca68685a6f572ff758fa6b1997d5f481c Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Thu, 14 Dec 2023 22:40:29 +0100 Subject: [PATCH] services: immich: create --- services/default.nix | 1 + services/immich.nix | 71 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 services/immich.nix diff --git a/services/default.nix b/services/default.nix index 221159c..86d2fe6 100644 --- a/services/default.nix +++ b/services/default.nix @@ -4,6 +4,7 @@ ./fail2ban.nix ./fava.nix ./gitea + ./immich.nix ./jellyfin.nix ./lohr.nix ./matrix.nix diff --git a/services/immich.nix b/services/immich.nix new file mode 100644 index 0000000..507e48e --- /dev/null +++ b/services/immich.nix @@ -0,0 +1,71 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit + (lib) + mkEnableOption + mkIf + mkOption + ; + + cfg = config.my.services.immich; + my = config.my; + + domain = config.networking.domain; + hostname = config.networking.hostName; + fqdn = "${hostname}.${domain}"; +in { + options.my.services.immich = let + inherit (lib) types; + in { + enable = mkEnableOption "Immich config"; + + home = mkOption { + type = types.str; + default = "/var/lib/immich"; + example = "/var/lib/immich"; + description = "Home for the immich service, where data will be stored"; + }; + + port = mkOption { + type = types.port; + example = 8080; + description = "Internal port for Immich webapp"; + }; + }; + + config = mkIf cfg.enable { + users.users.immich = { + isSystemUser = true; + home = cfg.home; + createHome = true; + group = "immich"; + }; + users.groups.immich = {}; + + services.nginx.virtualHosts = { + "immich.${domain}" = { + forceSSL = true; + useACMEHost = fqdn; + + locations."/" = { + proxyPass = "http://127.0.0.1:${toString cfg.port}"; + proxyWebsockets = true; + }; + + extraConfig = '' + proxy_connect_timeout 600; + proxy_read_timeout 600; + proxy_send_timeout 600; + client_max_body_size 100m; + access_log syslog:server=unix:/dev/log,tag=immich; + ''; + }; + }; + + security.acme.certs.${fqdn}.extraDomainNames = ["immich.${domain}"]; + }; +}