-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tandoor-recipes: init at 1.4.1 #191532
Merged
Merged
tandoor-recipes: init at 1.4.1 #191532
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e1db0a9
python310Packages.django-annoying: init at 0.10.6
ambroisie 5a4f2b5
python310Packages.django-autocomplete-light: init at 3.9.4
ambroisie 5c71b23
python310Packages.django-hcaptcha: init at 0.2.0
ambroisie 1c6d12b
python310Packages.django-crispy-forms: init at 1.14.0
ambroisie 20c95ad
python310Packages.django-js-reverse: init at 2022-09-16
ambroisie cdb9918
python310Packages.django-scopes: init at 1.2.0.post1
ambroisie 682ebaa
python310Packages.bleach-allowlist: init at 1.0.3
ambroisie 6505d75
python310Packages.jstyleson: init at 2022-09-16
ambroisie b0f1f71
python310Packages.microdata: init at 0.8.0
ambroisie f0b2aba
python310Packages.html-text: init at 0.5.2
ambroisie ac7c585
python310Packages.mf2py: init at 1.1.2
ambroisie 8c3ae39
python310Packages.pyrdfa3: init at 3.5.3
ambroisie 48919bc
python310Packages.extruct: init at 0.13.0
ambroisie d1710a2
python310Packages.language-tags: init at 1.1.0
ambroisie c9185db
python310Packages.recipe-scrapers: init at 14.14.0
ambroisie 81ab6b5
python310Packages.drf-writable-nested: init at 0.6.4
ambroisie f2a7a77
python310Packages.django-cors-headers: 3.7.0 -> 3.13.0
ambroisie 334ca79
python310Packages.django-oauth-toolkit: relax 'django' dependency
ambroisie 284e894
python310Packages.djangorestframework: fix 'collectstatic' with djang…
ambroisie 6a1359e
tandoor-recipes: init at 1.4.1
ambroisie d8b1d34
nixos/tandoor-recipes: init module
ambroisie 91ba846
nixos/tandoor-recipes: add test
ambroisie 83f5c2d
tandoor-recipes: add 'passthru.tests'
ambroisie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
{ config, pkgs, lib, ... }: | ||
|
||
with lib; | ||
let | ||
cfg = config.services.tandoor-recipes; | ||
pkg = cfg.package; | ||
|
||
# SECRET_KEY through an env file | ||
env = { | ||
GUNICORN_CMD_ARGS = "--bind=${cfg.address}:${toString cfg.port}"; | ||
DEBUG = "0"; | ||
MEDIA_ROOT = "/var/lib/tandoor-recipes"; | ||
} // optionalAttrs (config.time.timeZone != null) { | ||
TIMEZONE = config.time.timeZone; | ||
} // ( | ||
lib.mapAttrs (_: toString) cfg.extraConfig | ||
); | ||
|
||
manage = | ||
let | ||
setupEnv = lib.concatStringsSep "\n" (mapAttrsToList (name: val: "export ${name}=\"${val}\"") env); | ||
in | ||
pkgs.writeShellScript "manage" '' | ||
${setupEnv} | ||
exec ${pkg}/bin/tandoor-recipes "$@" | ||
''; | ||
in | ||
{ | ||
meta.maintainers = with maintainers; [ ambroisie ]; | ||
|
||
options.services.tandoor-recipes = { | ||
enable = mkOption { | ||
type = lib.types.bool; | ||
default = false; | ||
description = lib.mdDoc '' | ||
Enable Tandoor Recipes. | ||
|
||
When started, the Tandoor Recipes database is automatically created if | ||
it doesn't exist and updated if the package has changed. Both tasks are | ||
achieved by running a Django migration. | ||
|
||
A script to manage the instance (by wrapping Django's manage.py) is linked to | ||
`/var/lib/tandoor-recipes/tandoor-recipes-manage`. | ||
''; | ||
}; | ||
|
||
address = mkOption { | ||
type = types.str; | ||
default = "localhost"; | ||
description = lib.mdDoc "Web interface address."; | ||
}; | ||
|
||
port = mkOption { | ||
type = types.port; | ||
default = 8080; | ||
description = lib.mdDoc "Web interface port."; | ||
}; | ||
|
||
extraConfig = mkOption { | ||
type = types.attrs; | ||
default = { }; | ||
description = lib.mdDoc '' | ||
Extra tandoor recipes config options. | ||
|
||
See [the example dot-env file](https://raw.githubusercontent.com/vabene1111/recipes/master/.env.template) | ||
for available options. | ||
''; | ||
example = { | ||
ENABLE_SIGNUP = "1"; | ||
}; | ||
}; | ||
|
||
package = mkOption { | ||
type = types.package; | ||
default = pkgs.tandoor-recipes; | ||
defaultText = literalExpression "pkgs.tandoor-recipes"; | ||
description = lib.mdDoc "The Tandoor Recipes package to use."; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
systemd.services.tandoor-recipes = { | ||
description = "Tandoor Recipes server"; | ||
|
||
serviceConfig = { | ||
ExecStart = '' | ||
${pkg.python.pkgs.gunicorn}/bin/gunicorn recipes.wsgi | ||
''; | ||
Restart = "on-failure"; | ||
|
||
User = "tandoor_recipes"; | ||
DynamicUser = true; | ||
StateDirectory = "tandoor-recipes"; | ||
WorkingDirectory = "/var/lib/tandoor-recipes"; | ||
RuntimeDirectory = "tandoor-recipes"; | ||
|
||
BindReadOnlyPaths = [ | ||
"${config.environment.etc."ssl/certs/ca-certificates.crt".source}:/etc/ssl/certs/ca-certificates.crt" | ||
builtins.storeDir | ||
"-/etc/resolv.conf" | ||
"-/etc/nsswitch.conf" | ||
"-/etc/hosts" | ||
"-/etc/localtime" | ||
"-/run/postgresql" | ||
]; | ||
CapabilityBoundingSet = ""; | ||
LockPersonality = true; | ||
MemoryDenyWriteExecute = true; | ||
PrivateDevices = true; | ||
PrivateUsers = true; | ||
ProtectClock = true; | ||
ProtectControlGroups = true; | ||
ProtectHome = true; | ||
ProtectHostname = true; | ||
ProtectKernelLogs = true; | ||
ProtectKernelModules = true; | ||
ProtectKernelTunables = true; | ||
RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ]; | ||
RestrictNamespaces = true; | ||
RestrictRealtime = true; | ||
SystemCallArchitectures = "native"; | ||
# gunicorn needs setuid | ||
SystemCallFilter = [ "@system-service" "~@privileged" "@resources" "@setuid" "@keyring" ]; | ||
UMask = "0066"; | ||
} // lib.optionalAttrs (cfg.port < 1024) { | ||
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ]; | ||
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ]; | ||
}; | ||
|
||
wantedBy = [ "multi-user.target" ]; | ||
|
||
preStart = '' | ||
ln -sf ${manage} tandoor-recipes-manage | ||
|
||
# Let django migrate the DB as needed | ||
${pkg}/bin/tandoor-recipes migrate | ||
''; | ||
|
||
environment = env // { | ||
PYTHONPATH = "${pkg.python.pkgs.makePythonPath pkg.propagatedBuildInputs}:${pkg}/lib/tandoor-recipes"; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import ./make-test-python.nix ({ lib, ... }: { | ||
name = "tandoor-recipes"; | ||
meta.maintainers = with lib.maintainers; [ ambroisie ]; | ||
|
||
nodes.machine = { pkgs, ... }: { | ||
# Setup using Postgres | ||
services.tandoor-recipes = { | ||
enable = true; | ||
|
||
extraConfig = { | ||
DB_ENGINE = "django.db.backends.postgresql"; | ||
POSTGRES_HOST = "/run/postgresql"; | ||
POSTGRES_USER = "tandoor_recipes"; | ||
POSTGRES_DB = "tandoor_recipes"; | ||
}; | ||
}; | ||
|
||
services.postgresql = { | ||
enable = true; | ||
ensureDatabases = [ "tandoor_recipes" ]; | ||
ensureUsers = [ | ||
{ | ||
name = "tandoor_recipes"; | ||
ensurePermissions."DATABASE tandoor_recipes" = "ALL PRIVILEGES"; | ||
} | ||
]; | ||
}; | ||
|
||
systemd.services = { | ||
tandoor-recipes = { | ||
after = [ "postgresql.service" ]; | ||
}; | ||
}; | ||
}; | ||
|
||
testScript = '' | ||
machine.wait_for_unit("tandoor-recipes.service") | ||
|
||
with subtest("Web interface gets ready"): | ||
# Wait until server accepts connections | ||
machine.wait_until_succeeds("curl -fs localhost:8080") | ||
''; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
{ callPackage | ||
, nixosTests | ||
, 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 | ||
SuperSandro2000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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" | ||
SuperSandro2000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
runHook postInstall | ||
''; | ||
|
||
checkInputs = 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! | ||
''; | ||
}; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See ierror/django-js-reverse#114 for when this isn't needed anymore.