nixpkgs/pkgs/applications/misc/tandoor-recipes/default.nix
Peder Bergebakken Sundt 0e8902941b
Merge pull request #266469 from ambroisie/fix-tandoor-recipes
tandoor-recipes: fix `django-allauth`
2023-11-11 20:42:10 +02:00

165 lines
3.7 KiB
Nix

{ callPackage
, nixosTests
, python3
, fetchFromGitHub
, fetchpatch
}:
let
python = python3.override {
packageOverrides = self: super: {
django = super.django_4;
django-crispy-forms = super.django-crispy-forms.overridePythonAttrs (_: rec {
version = "1.14.0";
format = "setuptools";
src = fetchFromGitHub {
owner = "django-crispy-forms";
repo = "django-crispy-forms";
rev = "refs/tags/${version}";
hash = "sha256-NZ2lWxsQHc7Qc4HDoWgjJTZ/bJHmjpBf3q1LVLtzA+8=";
};
});
# Tests are incompatible with Django 4
django-js-reverse = super.django-js-reverse.overridePythonAttrs (_: {
doCheck = false;
});
};
};
common = callPackage ./common.nix { };
frontend = callPackage ./frontend.nix { };
in
python.pkgs.pythonPackages.buildPythonPackage rec {
pname = "tandoor-recipes";
inherit (common) version src;
format = "other";
patches = [
# Allow setting MEDIA_ROOT through environment variable
./media-root.patch
# https://github.com/TandoorRecipes/recipes/pull/2706
(fetchpatch {
url = "https://github.com/TandoorRecipes/recipes/commit/8f66f5c3ca61751a80cc133ff4c59019d6fca406.patch";
hash = "sha256-oF5YlPg1LEdLvKpxiSqjTmYPbrGquPlRIz6A05031gs=";
})
];
propagatedBuildInputs = with python.pkgs; [
beautifulsoup4
bleach
bleach-allowlist
boto3
cryptography
django
django-allauth
django-annoying
django-auth-ldap
django-autocomplete-light
django-cleanup
django-cors-headers
django-crispy-forms
django-hcaptcha
django-js-reverse
django-oauth-toolkit
django-prometheus
django-scopes
django-storages
django-tables2
django-webpack-loader
django-treebeard
djangorestframework
drf-writable-nested
gunicorn
icalendar
jinja2
lxml
markdown
microdata
pillow
psycopg2
pyppeteer
python-dotenv
pytube
pyyaml
recipe-scrapers
requests
six
uritemplate
validators
webdavclient3
whitenoise
];
configurePhase = ''
runHook preConfigure
ln -sf ${frontend}/ cookbook/static/vue
cp ${frontend}/webpack-stats.json vue/
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
# Disable debug logging
export DEBUG=0
# Avoid dependency on django debug toolbar
export DEBUG_TOOLBAR=0
# See https://github.com/TandoorRecipes/recipes/issues/2043
mkdir cookbook/static/themes/maps/
touch cookbook/static/themes/maps/style.min.css.map
touch cookbook/static/themes/bootstrap.min.css.map
touch cookbook/static/css/bootstrap-vue.min.css.map
${python.pythonOnBuildForHost.interpreter} manage.py collectstatic_js_reverse
${python.pythonOnBuildForHost.interpreter} manage.py collectstatic
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/lib
cp -r . $out/lib/tandoor-recipes
chmod +x $out/lib/tandoor-recipes/manage.py
makeWrapper $out/lib/tandoor-recipes/manage.py $out/bin/tandoor-recipes \
--prefix PYTHONPATH : "$PYTHONPATH"
# usually copied during frontend build (see vue.config.js)
cp vue/src/sw.js $out/lib/tandoor-recipes/cookbook/templates/
runHook postInstall
'';
nativeCheckInputs = with python.pkgs; [
pytestCheckHook
pytest-django
pytest-factoryboy
];
passthru = {
inherit frontend python;
updateScript = ./update.sh;
tests = {
inherit (nixosTests) tandoor-recipes;
};
};
meta = common.meta // {
description = ''
Application for managing recipes, planning meals, building shopping lists
and much much more!
'';
};
}