You can create a database, user and credentials by using clicks.services.postgres.databases.<name>
. You should set this to a file containing the password for your database user.
We recommend using our secrets module to create this password file.
clicks.services.postgres = { enable = true; databases.headscale = config.clicks.secrets."${lib.clicks.secrets.name ./headscale.sops.json}".paths.database_password; };
If your password file needs a specific group to read, you can use clicks.services.postgres.secretRequiredGroups
to allow postgres to read the file.
clicks.services.postgres.secretRequiredGroups = [ "headscale" ];
If you're using a systemd service to start your application, and you're runinng on the same machine as postgres, you may additionally want to ensure that postgres is always started and stopped in sequence with your service.
systemd.services.headscale.requires = [ "postgresql.service" ]; systemd.services.headscale.after = [ "postgresql.service" ];