aboutsummaryrefslogtreecommitdiff
path: root/modules/calibre/default.nix
blob: d177ac1c8bcba72d0fce5db5ee774a27b1fcc3ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{ config, pkgs, ... }:
let
  libDir = "/var/lib/calibre-web/library";
in {
  services = {
    calibre-web = {
      enable = true;

      listen = {
        ip = "127.0.0.1";
        port = 3020;
      };

      options = {
        calibreLibrary = libDir;
        enableBookUploading = true;
      };
    };

    nginx = {
      virtualHosts."library.internal" = {
        locations."/" = {
          proxyPass = "http://127.0.0.1:3020";
          proxyWebsockets = true;
        };
      };
    };
  };

  systemd.services.calibre-web = {
    preStart = ''
      if [ ! -f "${libDir}/metadata.db" ]; then
        mkdir -p "${libDir}"
        ${pkgs.calibre}/bin/calibredb add --empty \
          --with-library "${libDir}"
      fi
    '';
  };
}
Directive (EU) 2019/790, Article 4(3); all rights regarding Text and Data Mining (TDM) are reserved.