nix-config/modules/nixos/services/mealie/default.nix
Bruno BELANYI a9a1028164
All checks were successful
ci/woodpecker/push/check Pipeline was successful
WIP: add notes for missing persistence/backup
TODO:
* Look at for more inspiration https://github.com/nix-community/impermanence/pull/108
* Do home-manager
* Common files https://github.com/nix-community/impermanence/issues/10
2024-07-02 16:36:35 +00:00

79 lines
1.7 KiB
Nix

{ config, lib, ... }:
let
cfg = config.my.services.mealie;
in
{
options.my.services.mealie = with lib; {
enable = mkEnableOption "Mealie service";
port = mkOption {
type = types.port;
default = 4537;
example = 8080;
description = "Internal port for webui";
};
credentialsFile = mkOption {
type = types.str;
example = "/var/lib/mealie/credentials.env";
description = ''
Configuration file for secrets.
'';
};
};
config = lib.mkIf cfg.enable {
services.mealie = {
enable = true;
inherit (cfg) port credentialsFile;
settings = {
# Basic settings
BASE_URL = "https://mealie.${config.networking.domain}";
TZ = config.time.timeZone;
ALLOw_SIGNUP = "false";
# Use PostgreSQL
DB_ENGINE = "postgres";
# Make it work with socket auth
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;
}
];
};
my.services.nginx.virtualHosts = {
mealie = {
inherit (cfg) port;
extraConfig = {
# Allow bulk upload of recipes for import/export
locations."/".extraConfig = ''
client_max_body_size 0;
'';
};
};
};
# FIXME: backup
# FIXME: persistence
};
}