immich.nix 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. { config, lib, ... }:
  2. let
  3. cfg = config.services.immich;
  4. domain = "photos.t5.st";
  5. in
  6. {
  7. services.immich = {
  8. enable = true;
  9. host = "0.0.0.0";
  10. openFirewall = true;
  11. mediaLocation = "/mnt/storage/immich";
  12. group = "storage";
  13. accelerationDevices = [ "/dev/dri/renderD128" ];
  14. # environment = {
  15. # INFO: Not needed but left for reference
  16. # ENCODED_VIDEO_LOCATION = "/var/cache/immich/encoded-video";
  17. # MPLCONFIGDIR = "/var/cache/immich/mpl";
  18. # PROFILE_LOCATION = "/var/cache/immich/profile";
  19. # THUMB_LOCATION = "/var/cache/immich/thumbs";
  20. # };
  21. settings = {
  22. metadata.faces.import = true;
  23. newVersionCheck.enabled = false;
  24. server.externalDomain = "https://${domain}";
  25. storageTemplate = {
  26. enabled = true;
  27. hashVerificationEnabled = true;
  28. template = "{{y}}/{{MM}}/{{dd}}/{{filename}}";
  29. };
  30. # TODO: add smtp authentication to environment
  31. # notifications.smtp.enabled = true;
  32. # notifications.smtp.from = "Odin Photos <[email protected]>";
  33. };
  34. };
  35. services.cloudflared.tunnels."71c89a7f-2467-444c-9fda-4864860dc8c4" = {
  36. credentialsFile =
  37. config.age.secrets."odin/services/cloudflared-tunnel".path;
  38. default = "http_status:404";
  39. ingress."${domain}".service =
  40. "http://${cfg.host}:${toString cfg.port}";
  41. };
  42. services.caddy.virtualHosts.immich = {
  43. hostName = "photos.odin.t5.st";
  44. extraConfig = ''
  45. encode gzip zstd
  46. reverse_proxy ${cfg.host}:${toString cfg.port}
  47. '';
  48. };
  49. systemd.tmpfiles = {
  50. settings.immich."${cfg.mediaLocation}".e.mode =
  51. lib.mkForce "0750";
  52. rules = [
  53. "d /var/cache/immich 0750 immich storage - -"
  54. "d /var/cache/immich/mpl 0750 immich storage - -"
  55. "d /var/cache/immich/encoded-video 0750 immich storage - -"
  56. "d /var/cache/immich/profile 0750 immich storage - -"
  57. "d /var/cache/immich/thumbs 0750 immich storage - -"
  58. "L+ /var/cache/immich/encoded-video - - - - /mnt/storage/immich/encoded-video"
  59. "L+ /var/cache/immich/profile - - - - /mnt/storage/immich/profile"
  60. "L+ /var/cache/immich/thumbs - - - - /mnt/storage/immich/thumbs"
  61. ];
  62. };
  63. }