1 # Litestream {#module-services-litestream}
3 [Litestream](https://litestream.io/) is a standalone streaming
4 replication tool for SQLite.
6 ## Configuration {#module-services-litestream-configuration}
8 Litestream service is managed by a dedicated user named `litestream`
9 which needs permission to the database file. Here's an example config which gives
10 required permissions to access [grafana database](#opt-services.grafana.settings.database.path):
14 users.users.litestream.extraGroups = [ "grafana" ];
16 systemd.services.grafana.serviceConfig.ExecStartPost = "+" + pkgs.writeShellScript "grant-grafana-permissions" ''
19 while [ ! -f /var/lib/grafana/data/grafana.db ];
21 if [ "$timeout" == 0 ]; then
22 echo "ERROR: Timeout while waiting for /var/lib/grafana/data/grafana.db."
31 find /var/lib/grafana -type d -exec chmod -v 775 {} \;
32 find /var/lib/grafana -type f -exec chmod -v 660 {} \;
35 services.litestream = {
38 environmentFile = "/run/secrets/litestream";
43 path = "/var/lib/grafana/data/grafana.db";
45 url = "s3://mybkt.litestream.io/grafana";