mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 23:20:55 +00:00
calibre-web: init at 0.6.11
There are two patches applied to 'calibre-web' in order to make it more NixOS friendly: - default-logger.patch switches default log output to /dev/stdout, as otherwise calibre-web tries to open a file relative to its location, which it can't do as the store is read-only. It's not possible to pass log file location via command line flags. - run-migrations.patch adds an env var __RUN_MIGRATIONS_AND_EXIT that, when set, instructs calibre-web to run DB migrations and exit. As almost all config parameters are configured via UI in sqlite3 DB, this patch allows the DB to be pre-created so it can be updated by systemd pre-start script later. Thus, allowing calibre-web to be configured declaratively.
This commit is contained in:
parent
6259a47c45
commit
f069cdb0dc
14
pkgs/servers/calibre-web/db-migrations.patch
Normal file
14
pkgs/servers/calibre-web/db-migrations.patch
Normal file
|
@ -0,0 +1,14 @@
|
|||
diff --git a/cps/__init__.py b/cps/__init__.py
|
||||
index 627cca0b..233bb2dd 100644
|
||||
--- a/cps/__init__.py
|
||||
+++ b/cps/__init__.py
|
||||
@@ -87,6 +87,9 @@ db.CalibreDB.setup_db(config, cli.settingspath)
|
||||
|
||||
calibre_db = db.CalibreDB()
|
||||
|
||||
+if os.environ.get('__RUN_MIGRATIONS_AND_EXIT'):
|
||||
+ sys.exit(0)
|
||||
+
|
||||
def create_app():
|
||||
app.wsgi_app = ReverseProxied(app.wsgi_app)
|
||||
# For python2 convert path to unicode
|
17
pkgs/servers/calibre-web/default-logger.patch
Normal file
17
pkgs/servers/calibre-web/default-logger.patch
Normal file
|
@ -0,0 +1,17 @@
|
|||
diff --git a/cps/logger.py b/cps/logger.py
|
||||
index b204de31..3206e2bf 100644
|
||||
--- a/cps/logger.py
|
||||
+++ b/cps/logger.py
|
||||
@@ -32,10 +32,10 @@ ACCESS_FORMATTER_TORNADO = Formatter("[%(asctime)s] %(message)s")
|
||||
|
||||
FORMATTER = Formatter("[%(asctime)s] %(levelname)5s {%(name)s:%(lineno)d} %(message)s")
|
||||
DEFAULT_LOG_LEVEL = logging.INFO
|
||||
-DEFAULT_LOG_FILE = os.path.join(_CONFIG_DIR, "calibre-web.log")
|
||||
-DEFAULT_ACCESS_LOG = os.path.join(_CONFIG_DIR, "access.log")
|
||||
LOG_TO_STDERR = '/dev/stderr'
|
||||
LOG_TO_STDOUT = '/dev/stdout'
|
||||
+DEFAULT_LOG_FILE = LOG_TO_STDOUT
|
||||
+DEFAULT_ACCESS_LOG = LOG_TO_STDOUT
|
||||
|
||||
logging.addLevelName(logging.WARNING, "WARN")
|
||||
logging.addLevelName(logging.CRITICAL, "CRIT")
|
69
pkgs/servers/calibre-web/default.nix
Normal file
69
pkgs/servers/calibre-web/default.nix
Normal file
|
@ -0,0 +1,69 @@
|
|||
{ lib
|
||||
, fetchFromGitHub
|
||||
, python3
|
||||
, python3Packages
|
||||
}:
|
||||
|
||||
python3.pkgs.buildPythonApplication rec {
|
||||
pname = "calibre-web";
|
||||
version = "0.6.11";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "janeczku";
|
||||
repo = "calibre-web";
|
||||
rev = version;
|
||||
sha256 = "10sjllhhcamswpa1wlim4mbm2zl4g804bwly5p4nmklg7n1v226g";
|
||||
};
|
||||
|
||||
prePatch = ''
|
||||
substituteInPlace setup.cfg \
|
||||
--replace "requests>=2.11.1,<2.25.0" "requests>=2.11.1,<2.26.0" \
|
||||
--replace "cps = calibreweb:main" "calibre-web = calibreweb:main"
|
||||
'';
|
||||
|
||||
patches = [
|
||||
# default-logger.patch switches default logger to /dev/stdout. Otherwise calibre-web tries to open a file relative
|
||||
# to its location, which can't be done as the store is read-only. Log file location can later be configured using UI
|
||||
# if needed.
|
||||
./default-logger.patch
|
||||
# DB migrations adds an env var __RUN_MIGRATIONS_ANDEXIT that, when set, instructs calibre-web to run DB migrations
|
||||
# and exit. This is gonna be used to configure calibre-web declaratively, as most of its configuration parameters
|
||||
# are stored in the DB.
|
||||
./db-migrations.patch
|
||||
];
|
||||
|
||||
# calibre-web doesn't follow setuptools directory structure. The following is taken from the script
|
||||
# that calibre-web's maintainer is using to package it:
|
||||
# https://github.com/OzzieIsaacs/calibre-web-test/blob/master/build/make_release.py
|
||||
postPatch = ''
|
||||
mkdir -p src/calibreweb
|
||||
mv cps.py src/calibreweb/__init__.py
|
||||
mv cps src/calibreweb
|
||||
'';
|
||||
|
||||
# Upstream repo doesn't provide any tests.
|
||||
doCheck = false;
|
||||
|
||||
propagatedBuildInputs = with python3Packages; [
|
||||
backports_abc
|
||||
flask-babel
|
||||
flask_login
|
||||
flask_principal
|
||||
iso-639
|
||||
pypdf2
|
||||
requests
|
||||
singledispatch
|
||||
sqlalchemy
|
||||
tornado
|
||||
unidecode
|
||||
Wand
|
||||
];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Web app for browsing, reading and downloading eBooks stored in a Calibre database";
|
||||
maintainers = with maintainers; [ pborzenkov ];
|
||||
homepage = "https://github.com/janeczku/calibre-web";
|
||||
license = licenses.gpl3Plus;
|
||||
platforms = platforms.all;
|
||||
};
|
||||
}
|
|
@ -21817,6 +21817,8 @@ in
|
|||
|
||||
calibre = libsForQt5.callPackage ../applications/misc/calibre { };
|
||||
|
||||
calibre-web = callPackage ../servers/calibre-web { };
|
||||
|
||||
calligra = libsForQt5.callPackage ../applications/office/calligra {
|
||||
# Must use the same Qt version as Calligra itself:
|
||||
poppler = libsForQt5.poppler_0_61;
|
||||
|
|
Loading…
Reference in a new issue