1 { config, lib, pkgs, ...}:
3 cfg = config.services.mealie;
7 options.services.mealie = {
8 enable = lib.mkEnableOption "Mealie, a recipe manager and meal planner";
10 package = lib.mkPackageOption pkgs "mealie" { };
12 listenAddress = lib.mkOption {
15 description = "Address on which the service should listen.";
19 type = lib.types.port;
21 description = "Port on which to serve the Mealie service.";
24 settings = lib.mkOption {
25 type = with lib.types; attrsOf anything;
28 Configuration of the Mealie service.
30 See [the mealie documentation](https://nightly.mealie.io/documentation/getting-started/installation/backend-config/) for available options and default values.
33 ALLOW_SIGNUP = "false";
37 credentialsFile = lib.mkOption {
38 type = with lib.types; nullOr path;
40 example = "/run/secrets/mealie-credentials.env";
42 File containing credentials used in mealie such as {env}`POSTGRES_PASSWORD`
43 or sensitive LDAP options.
45 Expects the format of an `EnvironmentFile=`, as described by {manpage}`systemd.exec(5)`.
50 config = lib.mkIf cfg.enable {
51 systemd.services.mealie = {
52 description = "Mealie, a self hosted recipe manager and meal planner";
54 after = [ "network-online.target" ];
55 wants = [ "network-online.target" ];
56 wantedBy = [ "multi-user.target" ];
60 API_PORT = toString cfg.port;
61 BASE_URL = "http://localhost:${toString cfg.port}";
62 DATA_DIR = "/var/lib/mealie";
63 CRF_MODEL_PATH = "/var/lib/mealie/model.crfmodel";
64 } // (builtins.mapAttrs (_: val: toString val) cfg.settings);
69 ExecStartPre = "${pkg}/libexec/init_db";
70 ExecStart = "${lib.getExe pkg} -b ${cfg.listenAddress}:${builtins.toString cfg.port}";
71 EnvironmentFile = lib.mkIf (cfg.credentialsFile != null) cfg.credentialsFile;
72 StateDirectory = "mealie";
73 StandardOutput="journal";