1 { pkgs, lib, config, ... }:
4 domain = "sourcephile.fr";
6 calibre = config.services.calibre-server;
7 stateDir = "/var/lib/calibre";
10 # Beware, calibre pulls a lot of dependencies..
11 # TODO: The calibre server also supports systemd socket activation
12 services.calibre-server = {
17 "${stateDir}/libraries/julm"
19 # sudo -u calibre-server calibre-server --userdb /var/lib/calibre/users.sqlite --manage-users
23 userDb = "${stateDir}/users.sqlite";
26 systemd.services.calibre-server = {
29 StartLimitIntervalSec = "600s";
32 ExecStart = mkForce (escapeShellArgs ([
33 "${pkgs.calibre}/bin/calibre-server"
34 "--disable-use-bonjour"
38 (toString calibre.port)
39 ] ++ lib.optionals calibre.auth.enable [
45 ] ++ calibre.libraries));
46 MemoryAccounting = true;
49 Restart = mkForce "on-failure";
53 users.users.calibre-server.home = mkForce stateDir;
57 servers."${calibre.host}:${toString calibre.port}" = {
64 virtualHosts."${srv}.${domain}" = {
68 access_log /var/log/nginx/${domain}/${srv}/access.log json buffer=32k;
69 error_log /var/log/nginx/${domain}/${srv}/error.log;
72 proxyPass = "http://${srv}";
74 client_max_body_size 64m;
79 systemd.services.nginx = {
81 LogsDirectory = lib.mkForce [ "nginx/${domain}/${srv}" ];
84 services.sanoid.datasets."rpool/var/lib/${srv}" = {
85 use_template = [ "snap" ];