I have a NAS running NixOS with a HDD ZFS mirror and an NVMe SSD with ZFS on it. The SSD is mounted at /data/apps and I’d like Prometheus to write to /data/apps/prometheus, however there doesn’t seem to be a way to overwrite the default /var/lib/prometheus2/data (I’m aware of the stateDir option, it still doesn’t do what I want) just using services.prometheus or other options. I’d rather not create a custom Prometheus service just for this, since I don’t want to lose all of the nice stuff in nixpkgs.
My question here is partially a question of semantics; should I create a ZFS dataset that mounts to /var/lib/prometheus2/data or should I create the custom service?
Just from looking at the source in nixpkgs it looks like the tsdb path gets passed as a flag in the systemd service and IIRC flags override text config options in Prometheus.
{
# Workaround for prometheus to store data in another place
# https://www.freedesktop.org/software/systemd/man/latest/tmpfiles.d.html#Type
systemd.tmpfiles.rules = [
"D /data/apps/prometheus2 0751 prometheus prometheus - -"
"L+ /var/lib/prometheus2 - - - - /data/apps/prometheus2"
];
# ...
}