Hacking tt—rss to work as a portable service - gdamjan/tt-rss-service GitHub Wiki

⚠️⚠️ This is no longer needed, since tt-rss supports full configuration via environment variables. ⚠️⚠️

tt-rss (as many other php apps) expects to create a config.php file when first started. That won't work with a portable service, since the image is read-only and immutable (as is the nix-store, btw). Also the default config.php-dist file has certain assumptions about where it can store files, notably in the same directory as the php code files - which again will not work since that directory is part of the read-only and immutable image.

My solution is to provide a static config.php file that reads an additional config file from $CONFIGURATION_DIRECTORY/config.php, and uses $STATE_DIRECTORY as the root for the writeable directories (lock, cache and feed-icons).

  • CONFIGURATION_DIRECTORY is provided by systemd, and the ConfigurationDirectory=tt-rss directive, which maps the /etc/tt-rss/ directory from the host to the service. The file /etc/tt-rss/config.php is read first thing from the static config.php in tt-rss, so it's a good place to define the database info and the SELF_URL_PATH which we can't know up-front.

  • STATE_DIRECTORY is also provided by systemd, and the StateDirectory=tt-rss directive. systemd will create a writable directory for the service in /var/lib/private/tt-rss/ on the host and mount that as /var/lib/tt-rss/ in the service.

I have only tested this configuration with an already initialized database. I have not tested it when the DB is empty.