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 + ''; + + }; + + }; + +}