8 cfg = config.services.mealie;
12 options.services.mealie = {
13 enable = lib.mkEnableOption "Mealie, a recipe manager and meal planner";
15 package = lib.mkPackageOption pkgs "mealie" { };
17 listenAddress = lib.mkOption {
20 description = "Address on which the service should listen.";
24 type = lib.types.port;
26 description = "Port on which to serve the Mealie service.";
29 settings = lib.mkOption {
30 type = with lib.types; attrsOf anything;
33 Configuration of the Mealie service.
35 See [the mealie documentation](https://nightly.mealie.io/documentation/getting-started/installation/backend-config/) for available options and default values.
38 ALLOW_SIGNUP = "false";
42 credentialsFile = lib.mkOption {
43 type = with lib.types; nullOr path;
45 example = "/run/secrets/mealie-credentials.env";
47 File containing credentials used in mealie such as {env}`POSTGRES_PASSWORD`
48 or sensitive LDAP options.
50 Expects the format of an `EnvironmentFile=`, as described by {manpage}`systemd.exec(5)`.
55 config = lib.mkIf cfg.enable {
56 systemd.services.mealie = {
57 description = "Mealie, a self hosted recipe manager and meal planner";
59 after = [ "network-online.target" ];
60 wants = [ "network-online.target" ];
61 wantedBy = [ "multi-user.target" ];
65 API_PORT = toString cfg.port;
66 BASE_URL = "http://localhost:${toString cfg.port}";
67 DATA_DIR = "/var/lib/mealie";
68 CRF_MODEL_PATH = "/var/lib/mealie/model.crfmodel";
69 } // (builtins.mapAttrs (_: val: toString val) cfg.settings);
74 ExecStartPre = "${pkg}/libexec/init_db";
75 ExecStart = "${lib.getExe pkg} -b ${cfg.listenAddress}:${builtins.toString cfg.port}";
76 EnvironmentFile = lib.mkIf (cfg.credentialsFile != null) cfg.credentialsFile;
77 StateDirectory = "mealie";
78 StandardOutput = "journal";