From fb48b6b61214a8b2208b282df63e0c07704eb092 Mon Sep 17 00:00:00 2001 From: Shivaraj B H Date: Tue, 12 Mar 2024 22:35:35 +0530 Subject: [PATCH] docs(guide): dataDir init; unix-domain socket length limitation (#144) --------- Co-authored-by: Sridhar Ratnakumar <3998+srid@users.noreply.github.com> --- doc/guide.md | 4 ++++ doc/guide/datadir.md | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 doc/guide.md create mode 100644 doc/guide/datadir.md diff --git a/doc/guide.md b/doc/guide.md new file mode 100644 index 0000000..10b1da0 --- /dev/null +++ b/doc/guide.md @@ -0,0 +1,4 @@ + +# Guide + +- [[datadir]]# diff --git a/doc/guide/datadir.md b/doc/guide/datadir.md new file mode 100644 index 0000000..947c926 --- /dev/null +++ b/doc/guide/datadir.md @@ -0,0 +1,33 @@ +# Data directory + +`dataDir` is a an option present in all the services, allowing users to specify the directory where a given service will store its data files. Essentially, it is to persist the state of the service even when you exit the `process-compose` window. + +The `dataDir` of these services tend to take *relative* paths, which are usually relative to the project root. As such, when you run these services using `nix run`, their data files are created relative to whichever directory you are in. If you want these data files to always reside relative to the project directory, instead of using `nix run` consider wrapping the process-compose packages in script, via either [mission-control](https://community.flake.parts/mission-control) module or a [justfile](https://just.systems/). `services-flake` uses the latter. + +{#default-structure} +## Default data directory structure + +Let's say your project defines the following services: + +```nix +{ + # Inside `perSystem.process-compose.` + services.postgres.pg.enable = true; + services.redis.rd.enable = true; +} +``` + +The data directory structure will look like this: + +```sh +|-- data +| |-- pg +| |-- rd +``` + +## Gotchas + +{#socket-path} +### Unix-domain socket path is too long + +unix socket length is limited to [about 100 chars](https://linux.die.net/man/7/unix). If your data directory is nested too deep, you will have to set `dataDir` option of the service to a shorter path as a workaround.