0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 13:40:28 +03:00

nixos/mealie: add 'database.createLocally' (#403670)

This commit is contained in:
Bruno BELANYI 2025-05-06 13:45:40 +01:00 committed by GitHub
commit e8f532dea2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 52 additions and 10 deletions

View file

@ -50,13 +50,24 @@ in
Expects the format of an `EnvironmentFile=`, as described by {manpage}`systemd.exec(5)`.
'';
};
database = {
createLocally = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Configure local PostgreSQL database server for Mealie.
'';
};
};
};
config = lib.mkIf cfg.enable {
systemd.services.mealie = {
description = "Mealie, a self hosted recipe manager and meal planner";
after = [ "network-online.target" ];
after = [ "network-online.target" ] ++ lib.optional cfg.database.createLocally "postgresql.service";
requires = lib.optional cfg.database.createLocally "postgresql.service";
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
@ -78,5 +89,21 @@ in
StandardOutput = "journal";
};
};
services.mealie.settings = lib.mkIf cfg.database.createLocally {
DB_ENGINE = "postgres";
POSTGRES_URL_OVERRIDE = "postgresql://mealie:@/mealie?host=/run/postgresql";
};
services.postgresql = lib.mkIf cfg.database.createLocally {
enable = true;
ensureDatabases = [ "mealie" ];
ensureUsers = [
{
name = "mealie";
ensureDBOwnership = true;
}
];
};
};
}