overlay/mealie/default.nix
2024-01-10 00:33:04 +01:00

98 lines
2.4 KiB
Nix

{ 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 ];
};
}