From db0645075f91c3d31cc952fbad871dc3e8cae812 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 1 Oct 2022 21:39:36 +0000 Subject: [PATCH] setup calibre server --- hosts/oracle/default.nix | 1 + modules/services/calibre.nix | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 modules/services/calibre.nix diff --git a/hosts/oracle/default.nix b/hosts/oracle/default.nix index c9ab134..2d1ce42 100644 --- a/hosts/oracle/default.nix +++ b/hosts/oracle/default.nix @@ -21,5 +21,6 @@ nixpkgs.lib.nixosSystem { ../../modules/nixos ../../modules/hardware/server.nix ../../modules/services/sshd.nix + ../../modules/services/calibre.nix ]; } diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix new file mode 100644 index 0000000..4d5dbf9 --- /dev/null +++ b/modules/services/calibre.nix @@ -0,0 +1,41 @@ +{ config, pkgs, lib, ... }: + +let + + libraryPath = "${config.homePath}/media/books"; + +in { + + options = { }; + + config = { + services.calibre-server = { + enable = true; + libraries = [ libraryPath ]; + }; + + services.calibre-web = { + enable = true; + openFirewall = true; + options = { + reverseProxyAuth.enable = false; + enableBookConversion = true; + }; + }; + + home-manager.users.${config.user}.home.activation = { + + # Always create library directory if it doesn't exist + calibreLibrary = + config.home-manager.users.${config.user}.lib.dag.entryAfter + [ "writeBoundary" ] '' + if [ ! -d "${libraryPath}" ]; then + $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG ${libraryPath} + fi + ''; + + }; + + }; + +}