1{ lib, ... }:
2let
3 apiKey = "twentyfourcharacterskey!";
4in
5{
6 name = "cross-seed";
7 meta.maintainers = with lib.maintainers; [ pta2002 ];
8
9 nodes.machine =
10 { pkgs, config, ... }:
11 let
12 cfg = config.services.cross-seed;
13 in
14 {
15 systemd.tmpfiles.settings."0-cross-seed-test"."${cfg.settings.torrentDir}".d = {
16 inherit (cfg) user group;
17 mode = "700";
18 };
19
20 services.cross-seed = {
21 enable = true;
22 settings = {
23 torrentDir = "/var/lib/torrents";
24 torznab = [ ];
25 useClientTorrents = false;
26 };
27 # # We create this secret in the Nix store (making it readable by everyone).
28 # # DO NOT DO THIS OUTSIDE OF TESTS!!
29 settingsFile = (pkgs.formats.json { }).generate "secrets.json" {
30 inherit apiKey;
31 };
32 };
33 };
34
35 testScript = # python
36 ''
37 start_all()
38 machine.wait_for_unit("cross-seed.service")
39 machine.wait_for_open_port(2468)
40 # Check that the API is running
41 machine.succeed("curl --fail http://localhost:2468/api/ping?apiKey=${apiKey}")
42 '';
43}