summaryrefslogtreecommitdiff
path: root/content/theses/self-sufficiency/books.md
diff options
context:
space:
mode:
authoraethrvmn <me@aethrvmn.gr>2025-08-30 13:18:29 +0000
committeraethrvmn <me@aethrvmn.gr>2025-08-30 13:18:29 +0000
commit29a570918721fd5d73bb140a9fb3bfa3e5647b9f (patch)
treecfa54b3b7c1515ac6ae41d56f9b5e15ada4092b1 /content/theses/self-sufficiency/books.md
parentadded non-content (diff)
added content
Diffstat (limited to '')
-rw-r--r--content/theses/self-sufficiency/books.md95
1 files changed, 95 insertions, 0 deletions
diff --git a/content/theses/self-sufficiency/books.md b/content/theses/self-sufficiency/books.md
new file mode 100644
index 0000000..2bf583c
--- /dev/null
+++ b/content/theses/self-sufficiency/books.md
@@ -0,0 +1,95 @@
+---
+title: books
+weight: 30
+---
+Owning books (not reading them) is growing as a hobby in the digital age. I, as many others, still keep a collection of books that I occasionally read, mostly physical, but also digital.
+
+Unfortunately, some books are not easily accessible physically where I am, or I might want to read parts of a book to see if it is worth investing in buying an actual physical copy.
+
+For these reasons, among others, it is nice to have a nice, accessible web library to store your own books, and have access to them over the internet. For this reason, this guide shows you how to set up `calibre-web` as a self-hosted ebook library.
+
+## specs
+When idling, `calibre-web` takes 132M of RAM on my system.
+
+## installation
+
+Create a `calibre` folder and a `default.nix` file inside it, at the place where you have the rest of your nixos configuration
+```sh
+$ mkdir calibre && touch calibre/default.nix
+```
+(or use the file explorer of your choice)
+
+### nix declaration
+
+Open `calibre/default.nix` in any text editor, and copy the following
+```nix
+
+{ config, pkgs, ... }:
+{
+ services = {
+ calibre-web = {
+ enable = true;
+
+ listen = {
+ ip = "127.0.0.1";
+ port = 3020;
+ };
+
+ options = {
+ calibreLibrary = "/var/lib/calibre-web/library";
+ enableBookUploading = true;
+ };
+ };
+
+ nginx = {
+ virtualHosts."library.<YOUR-DOMAIN>" = {
+ enableACME = true;
+ forceSSL = true;
+
+ locations."/" = {
+ proxyPass = "http://127.0.0.1:3020";
+ proxyWebsockets = true;
+ };
+ };
+ };
+ };
+
+ systemd.services.calibre-web = {
+ preStart = ''
+ if [ ! -f "/var/lib/calibre-web/library/metadata.db" ]; then
+ mkdir -p "/var/lib/calibre-web/library"
+ ${pkgs.calibre}/bin/calibredb add --empty \
+ --with-library "/var/lib/calibre-web/library"
+ fi
+ '';
+ };
+}
+```
+
+Then to enable it, just include it in the server config file:
+```nix
+ imports = [
+ # ... other services
+ ./calibre
+ # ... other services
+ ];
+```
+and you're done.
+
+Let's break the config file down.
+
+### explanation
+1) We declare the `calibre-web` service as enabled
+2) We configure the port to 3020, and make it so it won't reach out to the web outside of the reverse proxy
+3) We set the library directory (where `calibre-web` will store your books), and enable uploading books via the web interface
+4) We set up the reverse proxy to allow you access through the web
+5) We set up a systemd service that runs when the `calibre-web` service runs, to verify that the location you set as a library is indeed a `calibre` database folder. If not, it initialised a `.db` file.
+
+### further setup
+Once the service is up and running, go to `localhost:3020`, or `library.<YOUR-DOMAIN>`, or whatever domain you set it to.
+
+You should see a login screen. The default `username` is `admin` and the default `password` is `admin123`.
+{{% hint danger %}}
+If you serve this over the open internet ***CHANGE THE DEFAULT USERNAME AND PASSWORD IMMEDIATELY AFTER LOGGING IN***.
+Otherwise *everyone* will have access to your library and data.
+{{% /hint %}}
Directive (EU) 2019/790, Article 4(3); all rights regarding Text and Data Mining (TDM) are reserved.