1import ./make-test-python.nix (
2 { pkgs, lib, ... }:
3
4 let
5 port = 3142;
6 defaultPort = 8083;
7 in
8 with lib;
9 {
10 name = "calibre-web";
11 meta.maintainers = with pkgs.lib.maintainers; [ pborzenkov ];
12
13 nodes = {
14 customized = { pkgs, ... }: {
15 services.calibre-web = {
16 enable = true;
17 listen.port = port;
18 options = {
19 calibreLibrary = "/tmp/books";
20 reverseProxyAuth = {
21 enable = true;
22 header = "X-User";
23 };
24 };
25 };
26 environment.systemPackages = [ pkgs.calibre ];
27 };
28 };
29 testScript = ''
30 start_all()
31
32 customized.succeed(
33 "mkdir /tmp/books && calibredb --library-path /tmp/books add -e --title test-book"
34 )
35 customized.succeed("systemctl restart calibre-web")
36 customized.wait_for_unit("calibre-web.service")
37 customized.wait_for_open_port(${toString port})
38 customized.succeed(
39 "curl --fail -H X-User:admin 'http://localhost:${toString port}' | grep test-book"
40 )
41 '';
42 }
43)