added mealie
This commit is contained in:
parent
88ce2e6a5f
commit
8d47f6b09c
11 changed files with 295 additions and 8 deletions
97
mealie/default.nix
Normal file
97
mealie/default.nix
Normal file
|
@ -0,0 +1,97 @@
|
|||
{ lib, callPackage, fetchFromGitHub, gnused, python3, python3Packages, writeShellScript }: let
|
||||
version = "1.0.0-RC2";
|
||||
src = fetchFromGitHub {
|
||||
owner = "mealie-recipes";
|
||||
repo = "mealie";
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-/sht8s0Nap6TdYxAqamKj/HGGV21/8eYCuYzpWXRJCE=";
|
||||
};
|
||||
|
||||
frontend = callPackage (import ./mealie-frontend.nix src version) { };
|
||||
|
||||
in python3Packages.buildPythonPackage rec {
|
||||
pname = "mealie";
|
||||
inherit version src;
|
||||
format = "pyproject";
|
||||
|
||||
patches = [
|
||||
./mealie_statedir.patch
|
||||
./mealie_init_db.patch
|
||||
./mealie_logger.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
python3Packages.poetry-core
|
||||
python3.pkgs.pythonRelaxDepsHook
|
||||
];
|
||||
|
||||
pythonRelaxDeps = true;
|
||||
|
||||
propagatedBuildInputs = with python3Packages; [
|
||||
aiofiles
|
||||
alembic
|
||||
aniso8601
|
||||
appdirs
|
||||
apprise
|
||||
bcrypt
|
||||
extruct
|
||||
fastapi
|
||||
gunicorn
|
||||
jinja2
|
||||
lxml
|
||||
orjson
|
||||
passlib
|
||||
pillow
|
||||
psycopg2
|
||||
pyhumps
|
||||
pytesseract
|
||||
python-dotenv
|
||||
python-jose
|
||||
python-ldap
|
||||
python-multipart
|
||||
python-slugify
|
||||
pyyaml
|
||||
rapidfuzz
|
||||
recipe-scrapers
|
||||
sqlalchemy
|
||||
uvicorn
|
||||
];
|
||||
|
||||
doCheck = true;
|
||||
|
||||
postInstall = let
|
||||
start_script = writeShellScript "start-mealie" ''
|
||||
export STATIC_FILES="${frontend}"
|
||||
${python3Packages.gunicorn}/bin/gunicorn "$@" -k uvicorn.workers.UvicornWorker mealie.app:app;
|
||||
'';
|
||||
in ''
|
||||
mkdir -p $out/config $out/bin
|
||||
${lib.getExe gnused} 's+script_location = alembic+script_location = ${src}/alembic+g' ${src}/alembic.ini > $out/config/alembic.ini
|
||||
|
||||
rm -f $out/bin/*
|
||||
ln -s $out/lib/${python3.libPrefix}/site-packages/mealie/db/init_db.py $out/bin/init_db.py
|
||||
cp ${start_script} $out/bin/start-mealie
|
||||
chmod +x $out/bin/start-mealie
|
||||
'';
|
||||
|
||||
checkInputs = with python3Packages; [
|
||||
pytestCheckHook
|
||||
];
|
||||
|
||||
passthru = {
|
||||
inherit python3;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "A Place for All Your Recipes";
|
||||
longDescription = ''
|
||||
Mealie is a self hosted recipe manager and meal planner with a RestAPI backend and a reactive frontend
|
||||
application built in NuxtJS for a pleasant user experience for the whole family. Easily add recipes into your
|
||||
database by providing the URL and Mealie will automatically import the relevant data or add a family recipe with
|
||||
the UI editor.
|
||||
'';
|
||||
homepage = "https://nightly.mealie.io";
|
||||
license = licenses.agpl3Only;
|
||||
maintainers = with maintainers; [ litchipi ];
|
||||
};
|
||||
}
|
46
mealie/mealie-frontend.nix
Normal file
46
mealie/mealie-frontend.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
src: version:
|
||||
{ lib, fetchYarnDeps, nodejs_18, prefetch-yarn-deps, stdenv, ... }: stdenv.mkDerivation {
|
||||
name = "mealie-frontend";
|
||||
inherit version;
|
||||
src = "${src}/frontend";
|
||||
|
||||
yarnOfflineCache = fetchYarnDeps {
|
||||
yarnLock = "${src}/frontend/yarn.lock";
|
||||
hash = "sha256-zQUD/PQWzp2Q6fiVmLicvSusXffu6s9q3x/aAUnCN38=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
prefetch-yarn-deps
|
||||
nodejs_18
|
||||
nodejs_18.pkgs.yarn
|
||||
];
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
export HOME=$(mktemp -d)
|
||||
yarn config --offline set yarn-offline-mirror "$yarnOfflineCache"
|
||||
fixup-yarn-lock yarn.lock
|
||||
command -v yarn
|
||||
yarn install --frozen-lockfile --offline --no-progress --non-interactive
|
||||
patchShebangs node_modules/
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
export NUXT_TELEMETRY_DISABLED=1
|
||||
yarn --offline build
|
||||
yarn --offline generate
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mv dist $out
|
||||
runHook postInstall
|
||||
'';
|
||||
}
|
25
mealie/mealie_init_db.patch
Normal file
25
mealie/mealie_init_db.patch
Normal file
|
@ -0,0 +1,25 @@
|
|||
diff --git a/mealie/db/init_db.py b/mealie/db/init_db.py
|
||||
index 90dd91a8..d19a5eac 100644
|
||||
--- a/mealie/db/init_db.py
|
||||
+++ b/mealie/db/init_db.py
|
||||
@@ -1,3 +1,4 @@
|
||||
+import os
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
from time import sleep
|
||||
@@ -85,7 +86,14 @@ def main():
|
||||
if max_retry == 0:
|
||||
raise ConnectionError("Database connection failed - exiting application.")
|
||||
|
||||
- alembic_cfg = Config(str(PROJECT_DIR / "alembic.ini"))
|
||||
+ alembic_cfg_path = os.getenv("ALEMBIC_CONFIG_FPATH")
|
||||
+ if not alembic_cfg_path:
|
||||
+ alembic_cfg_path = str(PROJECT_DIR / "alembic.ini")
|
||||
+
|
||||
+ if not os.path.isfile(alembic_cfg_path):
|
||||
+ raise Exception("Provided alembic config path doesn't exist")
|
||||
+
|
||||
+ alembic_cfg = Config(alembic_cfg_path)
|
||||
if db_is_at_head(alembic_cfg):
|
||||
logger.debug("Migration not needed.")
|
||||
else:
|
18
mealie/mealie_logger.patch
Normal file
18
mealie/mealie_logger.patch
Normal file
|
@ -0,0 +1,18 @@
|
|||
diff --git a/mealie/core/root_logger.py b/mealie/core/root_logger.py
|
||||
index 29db504f..30fc05dc 100644
|
||||
--- a/mealie/core/root_logger.py
|
||||
+++ b/mealie/core/root_logger.py
|
||||
@@ -9,7 +9,12 @@ DATA_DIR = determine_data_dir()
|
||||
|
||||
from .config import get_app_settings # noqa E402
|
||||
|
||||
-LOGGER_FILE = DATA_DIR.joinpath("mealie.log")
|
||||
+import os
|
||||
+
|
||||
+LOGGER_FILE = os.getenv("MEALIE_LOG_FILE")
|
||||
+if not LOGGER_FILE:
|
||||
+ LOGGER_FILE = DATA_DIR.joinpath("mealie.log")
|
||||
+
|
||||
DATE_FORMAT = "%d-%b-%y %H:%M:%S"
|
||||
LOGGER_FORMAT = "%(levelname)s: %(asctime)s \t%(message)s"
|
||||
|
25
mealie/mealie_statedir.patch
Normal file
25
mealie/mealie_statedir.patch
Normal file
|
@ -0,0 +1,25 @@
|
|||
diff --git a/mealie/core/config.py b/mealie/core/config.py
|
||||
index 7dae9b23..71769098 100644
|
||||
--- a/mealie/core/config.py
|
||||
+++ b/mealie/core/config.py
|
||||
@@ -19,15 +19,15 @@ DATA_DIR = os.getenv("DATA_DIR")
|
||||
|
||||
|
||||
def determine_data_dir() -> Path:
|
||||
- global PRODUCTION, TESTING, BASE_DIR, DATA_DIR
|
||||
+ global TESTING
|
||||
|
||||
if TESTING:
|
||||
return BASE_DIR.joinpath(DATA_DIR if DATA_DIR else "tests/.temp")
|
||||
|
||||
- if PRODUCTION:
|
||||
- return Path(DATA_DIR if DATA_DIR else "/app/data")
|
||||
-
|
||||
- return BASE_DIR.joinpath("dev", "data")
|
||||
+ state_dir = os.getenv("STATE_DIRECTORY")
|
||||
+ if not state_dir:
|
||||
+ raise Exception("State directory not set")
|
||||
+ return Path(state_dir)
|
||||
|
||||
|
||||
@lru_cache
|
Loading…
Add table
Add a link
Reference in a new issue