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 = {
18 "${stateDir}/libraries/julm"
20 # sudo -u calibre-server calibre-server --userdb /var/lib/calibre/users.sqlite --manage-users
24 userDb = "${stateDir}/users.sqlite";
28 systemd.services.calibre-server = {
31 StartLimitIntervalSec = "600s";
34 ExecStart = mkForce "${pkgs.calibre}/bin/calibre-server ${stateDir}/libraries/julm --auth-mode basic --listen-on 127.0.0.1 --port 17429 --userdb ${stateDir}/users.sqlite --enable-auth --disable-use-bonjour";
35 MemoryAccounting = true;
38 Restart = mkForce "on-failure";
42 users.users.calibre-server.home = mkForce stateDir;
46 servers."127.0.0.1:${toString calibre.port}" = {
53 virtualHosts."${srv}.${domain}" = {
57 access_log /var/log/nginx/${domain}/${srv}/access.log json buffer=32k;
58 error_log /var/log/nginx/${domain}/${srv}/error.log;
61 proxyPass = "http://${srv}";
63 client_max_body_size 64m;
68 systemd.services.nginx = {
70 LogsDirectory = lib.mkForce [ "nginx/${domain}/${srv}" ];
73 services.sanoid.datasets."rpool/var/lib/${srv}" = {
74 use_template = [ "snap" ];