1
0

immich.nix 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.caddy.virtualHosts.immich = {
  36. hostName = "photos.odin.t5.st";
  37. extraConfig = ''
  38. encode gzip zstd
  39. reverse_proxy ${cfg.host}:${toString cfg.port}
  40. '';
  41. };
  42. systemd.tmpfiles = {
  43. settings.immich."${cfg.mediaLocation}".e.mode = lib.mkForce "0750";
  44. rules = [
  45. "d /var/cache/immich 0750 immich storage - -"
  46. "d /var/cache/immich/mpl 0750 immich storage - -"
  47. "d /var/cache/immich/encoded-video 0750 immich storage - -"
  48. "d /var/cache/immich/profile 0750 immich storage - -"
  49. "d /var/cache/immich/thumbs 0750 immich storage - -"
  50. "L+ /var/cache/immich/encoded-video - - - - /mnt/storage/immich/encoded-video"
  51. "L+ /var/cache/immich/profile - - - - /mnt/storage/immich/profile"
  52. "L+ /var/cache/immich/thumbs - - - - /mnt/storage/immich/thumbs"
  53. ];
  54. };
  55. }