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 default = { ... }: {
15 services.calibre-web.enable = true;
16 };
17
18 customized = { pkgs, ... }: {
19 services.calibre-web = {
20 enable = true;
21 listen.port = port;
22 options = {
23 calibreLibrary = "/tmp/books";
24 reverseProxyAuth = {
25 enable = true;
26 header = "X-User";
27 };
28 };
29 };
30 environment.systemPackages = [ pkgs.calibre ];
31 };
32 };
33 testScript = ''
34 start_all()
35
36 default.wait_for_unit("calibre-web.service")
37 default.wait_for_open_port(${toString defaultPort})
38 default.succeed(
39 "curl --fail 'http://localhost:${toString defaultPort}/basicconfig' | grep -q 'Basic Configuration'"
40 )
41
42 customized.succeed(
43 "mkdir /tmp/books && calibredb --library-path /tmp/books add -e --title test-book"
44 )
45 customized.succeed("systemctl restart calibre-web")
46 customized.wait_for_unit("calibre-web.service")
47 customized.wait_for_open_port(${toString port})
48 customized.succeed(
49 "curl --fail -H X-User:admin 'http://localhost:${toString port}' | grep -q test-book"
50 )
51 '';
52 }
53)