There is a closed discussion on immich repo immich-app/immich#14815
Until immich supports better security, below method can be used to template a file with secrets on ramdisk. Circumventing the nixpkgs config generation parts, and pointing immich systemd service to this templated file.
{ config, ... }:
let
domain = config.networking.domain;