Setting Up Immich On NixOS with Clan
Today, I spent some time getting my photo setup together, (and away from manually uploading them to my storage box from time to time š¬).
So Iāve decided Iād give Immich (as a self-hostable photo solution on my server) a try.
In case you donāt know yet how to get and set up a server, take a look here: Setting Up A Server (with NixOS and Clan)
§ Setting up Immich
Setting Immich up with NixOS is relatively straightforward, at least at first glance:
services.immich = { enable = true; host = "photos.example.ts.net";};But since Iām not running a Tailscale network (yet, I guess?), I need to make my immich service reachable from the outside.
This looks like this:
services.immich = { enable = true;};
services.caddy = { enable = true; virtualHosts."photos.your.domain" = { extraConfig = '' reverse_proxy 127.0.0.1:2283 ''; };};For this to work, you need to:
- own a domain
- set a DNS A record to
photos-> āIPv4 IP of your serverā, e.g.1.12.234.45
If you donāt know how to do that, take a look here: Setting A DNS Record On A Domain
Now weāve got a machine running Immich thatās reachable from the outside via a domain.
Meaning: You should be able to go to https://photos.your.domain, and see the Immich login screen.
So thatās itāalmost.
§ Mounting a storage box
Weāve still got one problem:
The machine this is running on is the smallest Hetzner VPS: powerful enough to run Immich, but not large enough to host all the photos.
Itās got only 40GB of disk space, and upgrading that gets expensive fast.
So you probably donāt want to store photos on there.
Thankfully, Hetzner also has a service called a Storage Box.
A Storage Box has the opposite characteristics to a VPS: Itās pretty cheap per TB, but you canāt really run anything on it.
So, letās match the two.
What weāre going to do is the following:
We will mount the storage box as a file system into the folder in which Immich is going to store its data in.
For this, you need to:
- Have a Storage Box (so rent one)
- Create a new sub-account (with corresponding subfolder) on it. Save the password for this into your password manager
- Mount the subfolder into our server
Mounting the subfolder looks like this:
Writing in here is haphazardous, disjointed and sketchy.
It's probably a good idea to come back later.
services.immich = { enable = true;};
services.caddy = { enable = true; virtualHosts."photos.your.domain" = { extraConfig = '' reverse_proxy 127.0.0.1:2283 ''; };};environment.systemPackages = [ pkgs.cifs-utils ];fileSystems."/var/lib/immich" = { device = "//uXXXXXX-subX.your-storagebox.de/uXXXXXX-subX"; fsType = "cifs"; options = [ "x-systemd.automount" "noauto" "x-systemd.device-timeout=5s" "x-systemd.mount-timeout=5s" "credentials=${config.clan.core.vars.generators.storagebox-immich-secret.files."credentials".path}" "uid=immich" "gid=immich" ];};-
vars setup
-
add the secret to vars
-
issues
- immich canāt write or read the files
- with disabled machine learning the server dies, and I donāt know why
Writing in here is haphazardous, disjointed and sketchy.