services: mealie: get rid of copy-pasted module

This commit is contained in:
Antoine Martin 2025-01-17 16:58:14 +01:00
parent e0d3f8f6a7
commit 6aca4f9f62

View file

@ -29,64 +29,30 @@ in {
example = 8080; example = 8080;
description = "Internal port for Mealie webapp"; description = "Internal port for Mealie webapp";
}; };
credentialsFile = lib.mkOption {
type = types.nullOr types.path;
default = null;
example = "/run/secrets/mealie-credentials.env";
description = ''
File containing credentials used in mealie such as {env}`POSTGRES_PASSWORD`
or sensitive LDAP options.
Expects the format of an `EnvironmentFile=`, as described by {manpage}`systemd.exec(5)`.
'';
};
}; };
# FIXME(NixOS 24.11) Copy pasted from nixpkgs master module, because some needed changes weren't in stable yet. config = mkIf cfg.enable {
config = mkIf cfg.enable (let services.mealie = {
settings = { inherit listenAddress;
ALLOW_SIGNUP = "false";
BASE_URL = "https://mealie.${domain}";
TZ = config.time.timeZone;
# Use PostgreSQL enable = true;
DB_ENGINE = "postgres"; package = pkgs.unstable.mealie;
port = cfg.port;
# Settings for Mealie 1.7+ settings = {
POSTGRES_URL_OVERRIDE = "postgresql://mealie:@/mealie?host=/run/postgresql"; ALLOW_SIGNUP = "false";
}; BASE_URL = "https://mealie.${domain}";
in { TZ = config.time.timeZone;
systemd.services = { DB_ENGINE = "postgres";
mealie = { POSTGRES_URL_OVERRIDE = "postgresql://mealie:@/mealie?host=/run/postgresql";
after = ["network-online.target" "postgresql.service"];
requires = ["postgresql.service"];
wants = ["network-online.target"];
wantedBy = ["multi-user.target"];
description = "Mealie, a self hosted recipe manager and meal planner";
environment =
{
PRODUCTION = "true";
API_PORT = toString cfg.port;
BASE_URL = "http://localhost:${toString cfg.port}";
DATA_DIR = "/var/lib/mealie";
CRF_MODEL_PATH = "/var/lib/mealie/model.crfmodel";
}
// (builtins.mapAttrs (_: val: toString val) settings);
serviceConfig = {
DynamicUser = true;
User = "mealie";
ExecStartPre = "${pkg}/libexec/init_db";
ExecStart = "${lib.getExe pkg} -b ${listenAddress}:${builtins.toString cfg.port}";
EnvironmentFile = lib.mkIf (cfg.credentialsFile != null) cfg.credentialsFile;
StateDirectory = "mealie";
StandardOutput = "journal";
};
}; };
}; };
systemd.services.mealie = {
after = ["postgresql.service"];
requires = ["postgresql.service"];
};
# Set-up database # Set-up database
services.postgresql = { services.postgresql = {
enable = true; enable = true;
@ -118,5 +84,5 @@ in {
my.services.restic-backup = { my.services.restic-backup = {
paths = ["/var/lib/mealie"]; paths = ["/var/lib/mealie"];
}; };
}); };
} }