2024-02-01 07:29:41 +00:00
|
|
|
{ lib
|
2024-07-02 19:44:44 +00:00
|
|
|
, stdenv
|
2024-02-01 07:29:41 +00:00
|
|
|
, callPackage
|
|
|
|
, fetchFromGitHub
|
2024-08-12 20:23:36 +00:00
|
|
|
, fetchpatch
|
2024-02-01 07:29:41 +00:00
|
|
|
, makeWrapper
|
2024-02-01 07:30:57 +00:00
|
|
|
, nixosTests
|
2024-02-01 07:29:41 +00:00
|
|
|
, python3Packages
|
|
|
|
, writeShellScript
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2024-08-10 14:23:03 +00:00
|
|
|
version = "1.11.0";
|
2024-02-01 07:29:41 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "mealie-recipes";
|
|
|
|
repo = "mealie";
|
|
|
|
rev = "v${version}";
|
2024-08-10 14:23:03 +00:00
|
|
|
hash = "sha256-tBbvmM66zCNpKqeekPY48j0t5PjLHeyQ8+kJ6755ivo=";
|
2024-02-01 07:29:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
frontend = callPackage (import ./mealie-frontend.nix src version) { };
|
|
|
|
|
2024-05-24 12:32:57 +00:00
|
|
|
pythonpkgs = python3Packages;
|
2024-02-01 07:29:41 +00:00
|
|
|
python = pythonpkgs.python;
|
|
|
|
|
|
|
|
crfpp = stdenv.mkDerivation {
|
|
|
|
pname = "mealie-crfpp";
|
|
|
|
version = "unstable-2024-02-12";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "mealie-recipes";
|
|
|
|
repo = "crfpp";
|
|
|
|
rev = "c56dd9f29469c8a9f34456b8c0d6ae0476110516";
|
|
|
|
hash = "sha256-XNps3ZApU8m07bfPEnvip1w+3hLajdn9+L5+IpEaP0c=";
|
|
|
|
};
|
2024-07-02 19:44:44 +00:00
|
|
|
|
|
|
|
# Can remove once the `register` keyword is removed from source files
|
|
|
|
# Configure overwrites CXXFLAGS so patch it in the Makefile
|
|
|
|
postConfigure = lib.optionalString stdenv.cc.isClang ''
|
|
|
|
substituteInPlace Makefile \
|
|
|
|
--replace-fail "CXXFLAGS = " "CXXFLAGS = -std=c++14 "
|
|
|
|
'';
|
2024-02-01 07:29:41 +00:00
|
|
|
};
|
2024-07-02 19:44:44 +00:00
|
|
|
in
|
|
|
|
|
2024-08-10 19:57:03 +00:00
|
|
|
pythonpkgs.buildPythonApplication rec {
|
2024-02-01 07:29:41 +00:00
|
|
|
pname = "mealie";
|
|
|
|
inherit version src;
|
|
|
|
pyproject = true;
|
|
|
|
|
2024-08-12 20:23:36 +00:00
|
|
|
patches = [
|
|
|
|
# Pull in https://github.com/mealie-recipes/mealie/pull/4002 manually until
|
|
|
|
# it lands in an upstream mealie release.
|
|
|
|
# See https://github.com/NixOS/nixpkgs/issues/321623.
|
|
|
|
( fetchpatch {
|
|
|
|
url = "https://github.com/mealie-recipes/mealie/commit/65ece35966120479db903785b22e9f2645f72aa4.patch";
|
|
|
|
hash = "sha256-4Nc0dFJrZ7ElN9rrq+CFpayKsrRjRd24fYraUFTzcH8=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2024-08-10 19:57:03 +00:00
|
|
|
build-system = with pythonpkgs; [ poetry-core ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2024-02-01 07:29:41 +00:00
|
|
|
|
|
|
|
dontWrapPythonPrograms = true;
|
|
|
|
|
|
|
|
pythonRelaxDeps = true;
|
|
|
|
|
2024-08-10 19:57:03 +00:00
|
|
|
dependencies = with pythonpkgs; [
|
2024-02-01 07:29:41 +00:00
|
|
|
aiofiles
|
|
|
|
alembic
|
|
|
|
aniso8601
|
|
|
|
appdirs
|
|
|
|
apprise
|
2024-05-24 12:32:57 +00:00
|
|
|
authlib
|
2024-02-01 07:29:41 +00:00
|
|
|
bcrypt
|
|
|
|
extruct
|
|
|
|
fastapi
|
|
|
|
gunicorn
|
|
|
|
html2text
|
|
|
|
httpx
|
|
|
|
jinja2
|
|
|
|
lxml
|
2024-05-24 12:32:57 +00:00
|
|
|
openai
|
2024-02-01 07:29:41 +00:00
|
|
|
orjson
|
|
|
|
paho-mqtt
|
|
|
|
pillow
|
2024-05-24 12:32:57 +00:00
|
|
|
pillow-heif
|
2024-02-01 07:29:41 +00:00
|
|
|
psycopg2
|
2024-05-24 12:32:57 +00:00
|
|
|
pydantic-settings
|
2024-02-01 07:29:41 +00:00
|
|
|
pyhumps
|
2024-05-24 12:32:57 +00:00
|
|
|
pyjwt
|
2024-02-01 07:29:41 +00:00
|
|
|
python-dotenv
|
|
|
|
python-ldap
|
|
|
|
python-multipart
|
|
|
|
python-slugify
|
|
|
|
pyyaml
|
|
|
|
rapidfuzz
|
|
|
|
recipe-scrapers
|
|
|
|
sqlalchemy
|
|
|
|
tzdata
|
|
|
|
uvicorn
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
2024-08-10 14:23:27 +00:00
|
|
|
rm -rf dev # Do not need dev scripts & code
|
|
|
|
|
2024-02-01 07:29:41 +00:00
|
|
|
substituteInPlace mealie/__init__.py \
|
2024-05-07 23:52:02 +00:00
|
|
|
--replace-fail '__version__ = ' '__version__ = "v${version}" #'
|
2024-08-10 14:23:27 +00:00
|
|
|
|
|
|
|
substituteInPlace mealie/services/backups_v2/alchemy_exporter.py \
|
|
|
|
--replace-fail 'PROJECT_DIR = ' "PROJECT_DIR = Path('$out') #"
|
|
|
|
|
|
|
|
substituteInPlace mealie/db/init_db.py \
|
|
|
|
--replace-fail 'PROJECT_DIR = ' "PROJECT_DIR = Path('$out') #"
|
2024-02-01 07:29:41 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = let
|
|
|
|
start_script = writeShellScript "start-mealie" ''
|
|
|
|
${lib.getExe pythonpkgs.gunicorn} "$@" -k uvicorn.workers.UvicornWorker mealie.app:app;
|
|
|
|
'';
|
|
|
|
init_db = writeShellScript "init-mealie-db" ''
|
|
|
|
${python.interpreter} $OUT/${python.sitePackages}/mealie/scripts/install_model.py
|
|
|
|
${python.interpreter} $OUT/${python.sitePackages}/mealie/db/init_db.py
|
|
|
|
'';
|
|
|
|
in ''
|
2024-08-10 14:23:27 +00:00
|
|
|
mkdir -p $out/bin $out/libexec
|
2024-02-01 07:29:41 +00:00
|
|
|
rm -f $out/bin/*
|
|
|
|
|
2024-08-10 14:23:27 +00:00
|
|
|
substitute ${src}/alembic.ini $out/alembic.ini \
|
2024-02-01 07:29:41 +00:00
|
|
|
--replace-fail 'script_location = alembic' 'script_location = ${src}/alembic'
|
|
|
|
|
|
|
|
makeWrapper ${start_script} $out/bin/mealie \
|
2024-08-10 19:57:03 +00:00
|
|
|
--set PYTHONPATH "$out/${python.sitePackages}:${pythonpkgs.makePythonPath dependencies}" \
|
2024-02-01 07:29:41 +00:00
|
|
|
--set LD_LIBRARY_PATH "${crfpp}/lib" \
|
|
|
|
--set STATIC_FILES "${frontend}" \
|
|
|
|
--set PATH "${lib.makeBinPath [ crfpp ]}"
|
|
|
|
|
|
|
|
makeWrapper ${init_db} $out/libexec/init_db \
|
2024-08-10 19:57:03 +00:00
|
|
|
--set PYTHONPATH "$out/${python.sitePackages}:${pythonpkgs.makePythonPath dependencies}" \
|
2024-02-01 07:29:41 +00:00
|
|
|
--set OUT "$out"
|
|
|
|
'';
|
|
|
|
|
2024-08-10 19:57:03 +00:00
|
|
|
nativeCheckInputs = with pythonpkgs; [ pytestCheckHook ];
|
2024-02-01 07:29:41 +00:00
|
|
|
|
2024-08-10 20:22:44 +00:00
|
|
|
disabledTestPaths = [
|
|
|
|
# KeyError: 'alembic_version'
|
|
|
|
"tests/unit_tests/services_tests/backup_v2_tests/test_backup_v2.py"
|
|
|
|
"tests/unit_tests/services_tests/backup_v2_tests/test_alchemy_exporter.py"
|
|
|
|
# sqlite3.OperationalError: no such table
|
|
|
|
"tests/unit_tests/services_tests/scheduler/tasks/test_create_timeline_events.py"
|
|
|
|
"tests/unit_tests/test_ingredient_parser.py"
|
|
|
|
"tests/unit_tests/test_security.py"
|
|
|
|
];
|
|
|
|
|
2024-02-01 07:30:57 +00:00
|
|
|
passthru.tests = {
|
|
|
|
inherit (nixosTests) mealie;
|
|
|
|
};
|
|
|
|
|
2024-02-01 07:29:41 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Self hosted recipe manager and meal planner";
|
|
|
|
longDescription = ''
|
|
|
|
Mealie is a self hosted recipe manager and meal planner with a REST API 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://mealie.io";
|
|
|
|
changelog = "https://github.com/mealie-recipes/mealie/releases/tag/${src.rev}";
|
|
|
|
license = licenses.agpl3Only;
|
2024-05-07 00:10:27 +00:00
|
|
|
maintainers = with maintainers; [ litchipi anoa ];
|
2024-02-01 07:29:41 +00:00
|
|
|
mainProgram = "mealie";
|
|
|
|
};
|
|
|
|
}
|