tandoor-recipes: init at 1.4.1
This commit is contained in:
parent
284e89493f
commit
6a1359e4a2
6 changed files with 272 additions and 0 deletions
19
pkgs/applications/misc/tandoor-recipes/common.nix
Normal file
19
pkgs/applications/misc/tandoor-recipes/common.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ lib, fetchFromGitHub }:
|
||||
rec {
|
||||
version = "1.4.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "TandoorRecipes";
|
||||
repo = "recipes";
|
||||
rev = version;
|
||||
sha256 = "sha256-Q/IwjSByCUXVYxhk3U7oWvlMxrJxyajhpsRyq67PVHY=";
|
||||
};
|
||||
|
||||
yarnSha256 = "sha256-gH0q3pJ2BC5pAU9KSo3C9DDRUnpypoyLOEqKSrkxYrk=";
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://tandoor.dev/";
|
||||
license = licenses.agpl3Only;
|
||||
maintainers = with maintainers; [ ambroisie ];
|
||||
};
|
||||
}
|
135
pkgs/applications/misc/tandoor-recipes/default.nix
Normal file
135
pkgs/applications/misc/tandoor-recipes/default.nix
Normal file
|
@ -0,0 +1,135 @@
|
|||
{ callPackage
|
||||
, python3
|
||||
}:
|
||||
let
|
||||
python = python3.override {
|
||||
packageOverrides = self: super: {
|
||||
django = super.django_4;
|
||||
|
||||
# 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
|
||||
];
|
||||
|
||||
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
|
||||
|
||||
# Avoid dependency on django debug toolbar
|
||||
export DEBUG=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.pythonForBuild.interpreter} manage.py collectstatic_js_reverse
|
||||
${python.pythonForBuild.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"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
checkInputs = with python.pkgs; [
|
||||
pytestCheckHook
|
||||
pytest-django
|
||||
pytest-factoryboy
|
||||
];
|
||||
|
||||
passthru = {
|
||||
inherit frontend python;
|
||||
|
||||
updateScript = ./update.sh;
|
||||
};
|
||||
|
||||
meta = common.meta // {
|
||||
description = ''
|
||||
Application for managing recipes, planning meals, building shopping lists
|
||||
and much much more!
|
||||
'';
|
||||
};
|
||||
}
|
57
pkgs/applications/misc/tandoor-recipes/frontend.nix
Normal file
57
pkgs/applications/misc/tandoor-recipes/frontend.nix
Normal file
|
@ -0,0 +1,57 @@
|
|||
{ stdenv, fetchYarnDeps, fixup_yarn_lock, callPackage, nodejs-16_x }:
|
||||
let
|
||||
common = callPackage ./common.nix { };
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "tandoor-recipes-frontend";
|
||||
inherit (common) version;
|
||||
|
||||
src = "${common.src}/vue";
|
||||
|
||||
yarnOfflineCache = fetchYarnDeps {
|
||||
yarnLock = "${common.src}/vue/yarn.lock";
|
||||
sha256 = common.yarnSha256;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
fixup_yarn_lock
|
||||
# Use Node JS 16 because of @achrinza/node-ipc@9.2.2
|
||||
nodejs-16_x
|
||||
nodejs-16_x.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
|
||||
|
||||
yarn --offline run build
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
cp -R ../cookbook/static/vue/ $out
|
||||
cp webpack-stats.json $out
|
||||
echo "${common.version}" > "$out/version"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = common.meta // {
|
||||
description = "Tandoor Recipes frontend";
|
||||
};
|
||||
}
|
17
pkgs/applications/misc/tandoor-recipes/media-root.patch
Normal file
17
pkgs/applications/misc/tandoor-recipes/media-root.patch
Normal file
|
@ -0,0 +1,17 @@
|
|||
diff --git a/recipes/settings.py b/recipes/settings.py
|
||||
index 5676fe0a..6c6f1747 100644
|
||||
--- a/recipes/settings.py
|
||||
+++ b/recipes/settings.py
|
||||
@@ -426,10 +426,10 @@ if os.getenv('S3_ACCESS_KEY', ''):
|
||||
AWS_S3_CUSTOM_DOMAIN = os.getenv('S3_CUSTOM_DOMAIN', '')
|
||||
|
||||
MEDIA_URL = os.getenv('MEDIA_URL', '/media/')
|
||||
- MEDIA_ROOT = os.path.join(BASE_DIR, "mediafiles")
|
||||
+ MEDIA_ROOT = os.getenv('MEDIA_ROOT', os.path.join(BASE_DIR, "mediafiles"))
|
||||
else:
|
||||
MEDIA_URL = os.getenv('MEDIA_URL', '/media/')
|
||||
- MEDIA_ROOT = os.path.join(BASE_DIR, "mediafiles")
|
||||
+ MEDIA_ROOT = os.getenv('MEDIA_ROOT', os.path.join(BASE_DIR, "mediafiles"))
|
||||
|
||||
# Serve static files with gzip
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
42
pkgs/applications/misc/tandoor-recipes/update.sh
Executable file
42
pkgs/applications/misc/tandoor-recipes/update.sh
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -I nixpkgs=../../../../ -i bash -p nix wget prefetch-yarn-deps nix-prefetch-github jq
|
||||
|
||||
# shellcheck shell=bash
|
||||
|
||||
if [ -n "$GITHUB_TOKEN" ]; then
|
||||
TOKEN_ARGS=(--header "Authorization: token $GITHUB_TOKEN")
|
||||
fi
|
||||
|
||||
if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then
|
||||
echo "Regenerates packaging data for the tandoor-recipes package."
|
||||
echo "Usage: $0 [git release tag]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version="$1"
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ -z "$version" ]; then
|
||||
version="$(wget -O- "${TOKEN_ARGS[@]}" "https://api.github.com/repos/TandoorRecipes/recipes/releases?per_page=1" | jq -r '.[0].tag_name')"
|
||||
fi
|
||||
|
||||
package_src="https://raw.githubusercontent.com/TandoorRecipes/recipes/$version"
|
||||
|
||||
src_hash=$(nix-prefetch-github TandoorRecipes recipes --rev "${version}" | jq -r .sha256)
|
||||
|
||||
tmpdir=$(mktemp -d)
|
||||
trap 'rm -rf "$tmpdir"' EXIT
|
||||
|
||||
pushd "$tmpdir"
|
||||
wget "${TOKEN_ARGS[@]}" "$package_src/vue/yarn.lock"
|
||||
yarn_hash=$(prefetch-yarn-deps yarn.lock)
|
||||
popd
|
||||
|
||||
# Use friendlier hashes
|
||||
src_hash=$(nix hash to-sri --type sha256 "$src_hash")
|
||||
yarn_hash=$(nix hash to-sri --type sha256 "$yarn_hash")
|
||||
|
||||
sed -i -E -e "s#version = \".*\"#version = \"$version\"#" common.nix
|
||||
sed -i -E -e "s#sha256 = \".*\"#sha256 = \"$src_hash\"#" common.nix
|
||||
sed -i -E -e "s#yarnSha256 = \".*\"#yarnSha256 = \"$yarn_hash\"#" common.nix
|
|
@ -11545,6 +11545,8 @@ with pkgs;
|
|||
inherit (callPackages ../applications/networking/taler { })
|
||||
taler-exchange taler-merchant;
|
||||
|
||||
tandoor-recipes = callPackage ../applications/misc/tandoor-recipes { };
|
||||
|
||||
tangram = callPackage ../applications/networking/instant-messengers/tangram { };
|
||||
|
||||
t1utils = callPackage ../tools/misc/t1utils { };
|
||||
|
|
Loading…
Reference in a new issue