From 0ed148eb6629b0885ffc528629fa0c296c715974 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Wed, 3 Jul 2024 21:29:29 +0200 Subject: [PATCH] services: mealie: use postgres --- services/mealie.nix | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/services/mealie.nix b/services/mealie.nix index 3f46e29..7ceebe0 100644 --- a/services/mealie.nix +++ b/services/mealie.nix @@ -37,9 +37,48 @@ in { settings = { ALLOW_SIGNUP = "false"; + BASE_URL = "https://mealie.${domain}"; + TZ = config.time.timeZone; + + # Use PostgreSQL + DB_ENGINE = "postgres"; + + # Settings for Mealie 1.2 + POSTGRES_USER = "mealie"; + POSTGRES_PASSWORD = ""; + POSTGRES_SERVER = "/run/postgresql"; + # Pydantic and/or mealie doesn't handle the URI correctly, hijack it + # with query parameters... + POSTGRES_DB = "mealie?host=/run/postgresql&dbname=mealie"; + + # Settings for Mealie 1.7+, when that gets into NixOS stable + # POSTGRES_URL_OVERRIDE = "postgresql://mealie:@/mealie?host=/run/postgresql"; }; }; + systemd.services = { + mealie = { + after = [ "postgresql.service" ]; + requires = [ "postgresql.service" ]; + }; + }; + + # Set-up database + services.postgresql = { + enable = true; + ensureDatabases = [ "mealie" ]; + ensureUsers = [ + { + name = "mealie"; + ensureDBOwnership = true; + } + ]; + }; + + services.postgresqlBackup = { + databases = ["mealie"]; + }; + services.nginx.virtualHosts."mealie.${domain}" = { forceSSL = true; useACMEHost = fqdn;