added mealie
This commit is contained in:
parent
88ce2e6a5f
commit
8d47f6b09c
12
default.nix
12
default.nix
|
@ -5,17 +5,15 @@ self: super: {
|
||||||
python3 = super.python3.override {
|
python3 = super.python3.override {
|
||||||
packageOverrides = python-self: python-super: {
|
packageOverrides = python-self: python-super: {
|
||||||
pytapo = python-self.callPackage ./pytapo { };
|
pytapo = python-self.callPackage ./pytapo { };
|
||||||
brother-ql = python-self.callPackage ./brother-ql.nix { };
|
brother-ql = python-self.callPackage ./brother-ql { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#gotosocial = super.callPackage ./gotosocial { };
|
#gotosocial = super.callPackage ./gotosocial { };
|
||||||
pulse-secure = super.callPackage ./pulse-secure { };
|
pulse-secure = super.callPackage ./pulse-secure { };
|
||||||
studio-link = super.callPackage ./studio-link.nix { };
|
studio-link = super.callPackage ./studio-link { };
|
||||||
|
|
||||||
nginxModules = super.recurseIntoAttrs (super.callPackage ./nginx/modules.nix { });
|
nginxModules = super.recurseIntoAttrs (super.callPackage ./nginx/modules.nix { });
|
||||||
|
libedgetpu = self.callPackage ./libedgetpu { };
|
||||||
libedgetpu = self.callPackage ./libedgetpu {};
|
neolink = self.callPackage ./neolink { };
|
||||||
|
mealie = self.callPackage ./mealie { };
|
||||||
neolink = self.callPackage ./neolink.nix {};
|
|
||||||
}
|
}
|
||||||
|
|
97
mealie/default.nix
Normal file
97
mealie/default.nix
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
{ 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 ];
|
||||||
|
};
|
||||||
|
}
|
46
mealie/mealie-frontend.nix
Normal file
46
mealie/mealie-frontend.nix
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
src: version:
|
||||||
|
{ lib, fetchYarnDeps, nodejs_18, prefetch-yarn-deps, stdenv, ... }: stdenv.mkDerivation {
|
||||||
|
name = "mealie-frontend";
|
||||||
|
inherit version;
|
||||||
|
src = "${src}/frontend";
|
||||||
|
|
||||||
|
yarnOfflineCache = fetchYarnDeps {
|
||||||
|
yarnLock = "${src}/frontend/yarn.lock";
|
||||||
|
hash = "sha256-zQUD/PQWzp2Q6fiVmLicvSusXffu6s9q3x/aAUnCN38=";
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
prefetch-yarn-deps
|
||||||
|
nodejs_18
|
||||||
|
nodejs_18.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
|
||||||
|
|
||||||
|
export NUXT_TELEMETRY_DISABLED=1
|
||||||
|
yarn --offline build
|
||||||
|
yarn --offline generate
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
mv dist $out
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
}
|
25
mealie/mealie_init_db.patch
Normal file
25
mealie/mealie_init_db.patch
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
diff --git a/mealie/db/init_db.py b/mealie/db/init_db.py
|
||||||
|
index 90dd91a8..d19a5eac 100644
|
||||||
|
--- a/mealie/db/init_db.py
|
||||||
|
+++ b/mealie/db/init_db.py
|
||||||
|
@@ -1,3 +1,4 @@
|
||||||
|
+import os
|
||||||
|
from collections.abc import Callable
|
||||||
|
from pathlib import Path
|
||||||
|
from time import sleep
|
||||||
|
@@ -85,7 +86,14 @@ def main():
|
||||||
|
if max_retry == 0:
|
||||||
|
raise ConnectionError("Database connection failed - exiting application.")
|
||||||
|
|
||||||
|
- alembic_cfg = Config(str(PROJECT_DIR / "alembic.ini"))
|
||||||
|
+ alembic_cfg_path = os.getenv("ALEMBIC_CONFIG_FPATH")
|
||||||
|
+ if not alembic_cfg_path:
|
||||||
|
+ alembic_cfg_path = str(PROJECT_DIR / "alembic.ini")
|
||||||
|
+
|
||||||
|
+ if not os.path.isfile(alembic_cfg_path):
|
||||||
|
+ raise Exception("Provided alembic config path doesn't exist")
|
||||||
|
+
|
||||||
|
+ alembic_cfg = Config(alembic_cfg_path)
|
||||||
|
if db_is_at_head(alembic_cfg):
|
||||||
|
logger.debug("Migration not needed.")
|
||||||
|
else:
|
18
mealie/mealie_logger.patch
Normal file
18
mealie/mealie_logger.patch
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
diff --git a/mealie/core/root_logger.py b/mealie/core/root_logger.py
|
||||||
|
index 29db504f..30fc05dc 100644
|
||||||
|
--- a/mealie/core/root_logger.py
|
||||||
|
+++ b/mealie/core/root_logger.py
|
||||||
|
@@ -9,7 +9,12 @@ DATA_DIR = determine_data_dir()
|
||||||
|
|
||||||
|
from .config import get_app_settings # noqa E402
|
||||||
|
|
||||||
|
-LOGGER_FILE = DATA_DIR.joinpath("mealie.log")
|
||||||
|
+import os
|
||||||
|
+
|
||||||
|
+LOGGER_FILE = os.getenv("MEALIE_LOG_FILE")
|
||||||
|
+if not LOGGER_FILE:
|
||||||
|
+ LOGGER_FILE = DATA_DIR.joinpath("mealie.log")
|
||||||
|
+
|
||||||
|
DATE_FORMAT = "%d-%b-%y %H:%M:%S"
|
||||||
|
LOGGER_FORMAT = "%(levelname)s: %(asctime)s \t%(message)s"
|
||||||
|
|
25
mealie/mealie_statedir.patch
Normal file
25
mealie/mealie_statedir.patch
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
diff --git a/mealie/core/config.py b/mealie/core/config.py
|
||||||
|
index 7dae9b23..71769098 100644
|
||||||
|
--- a/mealie/core/config.py
|
||||||
|
+++ b/mealie/core/config.py
|
||||||
|
@@ -19,15 +19,15 @@ DATA_DIR = os.getenv("DATA_DIR")
|
||||||
|
|
||||||
|
|
||||||
|
def determine_data_dir() -> Path:
|
||||||
|
- global PRODUCTION, TESTING, BASE_DIR, DATA_DIR
|
||||||
|
+ global TESTING
|
||||||
|
|
||||||
|
if TESTING:
|
||||||
|
return BASE_DIR.joinpath(DATA_DIR if DATA_DIR else "tests/.temp")
|
||||||
|
|
||||||
|
- if PRODUCTION:
|
||||||
|
- return Path(DATA_DIR if DATA_DIR else "/app/data")
|
||||||
|
-
|
||||||
|
- return BASE_DIR.joinpath("dev", "data")
|
||||||
|
+ state_dir = os.getenv("STATE_DIRECTORY")
|
||||||
|
+ if not state_dir:
|
||||||
|
+ raise Exception("State directory not set")
|
||||||
|
+ return Path(state_dir)
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
#./gotosocial.nix
|
#./gotosocial.nix
|
||||||
|
./mealie.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
77
modules/mealie.nix
Normal file
77
modules/mealie.nix
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
{ config, lib, pkgs, ...}:
|
||||||
|
let
|
||||||
|
cfg = config.services.mealie;
|
||||||
|
pkg = pkgs.mealie;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.mealie = {
|
||||||
|
enable = lib.mkEnableOption "Mealie, a recipe manager and meal planner";
|
||||||
|
|
||||||
|
listen_address = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "0.0.0.0";
|
||||||
|
description = "Address on which the service should listen";
|
||||||
|
};
|
||||||
|
|
||||||
|
port = lib.mkOption {
|
||||||
|
type = lib.types.port;
|
||||||
|
default = 9000;
|
||||||
|
description = "Port on which to serve the Mealie service";
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig = lib.mkOption {
|
||||||
|
type = lib.types.attrs;
|
||||||
|
default = {};
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Some extra configuration for the service.
|
||||||
|
See [the mealie documentation](https://nightly.mealie.io/documentation/getting-started/installation/backend-config/) for available options and default values.
|
||||||
|
'';
|
||||||
|
example = {
|
||||||
|
ALLOW_SIGNUP = "false";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
credentialsFile = lib.mkOption {
|
||||||
|
type = with lib.types; nullOr path;
|
||||||
|
default = null;
|
||||||
|
example = "/run/secrets/mealie-credentials.env";
|
||||||
|
description = ''
|
||||||
|
File containing credentials used in mealie such as POSTGRES_PASSWORD
|
||||||
|
or sensitive LDAP options.
|
||||||
|
|
||||||
|
Expects the format of an EnvironmentFile=, as described by systemd.exec(5).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
systemd.services.mealie = {
|
||||||
|
description = "Mealie, a self hosted recipe manager and meal planner";
|
||||||
|
after = [
|
||||||
|
"network.target"
|
||||||
|
"network-online.target"
|
||||||
|
];
|
||||||
|
wantedBy = [
|
||||||
|
"multi-user.target"
|
||||||
|
];
|
||||||
|
|
||||||
|
environment = {
|
||||||
|
PYTHONPATH = "${pkg.python3.pkgs.makePythonPath pkg.propagatedBuildInputs}:${pkg}/lib/${pkg.python3.libPrefix}/site-packages";
|
||||||
|
PRODUCTION = "true";
|
||||||
|
MEALIE_LOG_FILE = "/var/log/mealie/mealie.log";
|
||||||
|
ALEMBIC_CONFIG_FPATH="${pkg}/config/alembic.ini";
|
||||||
|
API_PORT = builtins.toString cfg.port;
|
||||||
|
} // (builtins.mapAttrs (_: val: builtins.toString val) cfg.extraConfig);
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
DynamicUser = true;
|
||||||
|
User = "mealie";
|
||||||
|
ExecStartPre = "${pkg.python3.interpreter} ${pkg}/bin/init_db.py";
|
||||||
|
ExecStart = "${pkg}/bin/start-mealie -b ${cfg.listen_address}:${builtins.toString cfg.port}";
|
||||||
|
EnvironmentFile = lib.optional (cfg.credentialsFile != null) cfg.credentialsFile;
|
||||||
|
StateDirectory = "mealie";
|
||||||
|
LogsDirectory = "mealie";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue