1{ lib, pkgs, ... }:
2{
3 name = "ttyd";
4 meta.maintainers = with lib.maintainers; [ stunkymonkey ];
5
6 nodes.readonly =
7 { pkgs, ... }:
8 {
9 services.ttyd = {
10 enable = true;
11 entrypoint = [ (lib.getExe pkgs.htop) ];
12 writeable = false;
13 };
14 };
15
16 nodes.writeable =
17 { pkgs, ... }:
18 {
19 services.ttyd = {
20 enable = true;
21 username = "foo";
22 passwordFile = pkgs.writeText "password" "bar";
23 writeable = true;
24 };
25 };
26
27 testScript = ''
28 for machine in [readonly, writeable]:
29 machine.wait_for_unit("ttyd.service")
30 machine.wait_for_open_port(7681)
31 response = machine.succeed("curl -vvv -u foo:bar -s -H 'Host: ttyd' http://127.0.0.1:7681/")
32 assert '<title>ttyd - Terminal</title>' in response, "Page didn't load successfully"
33 '';
34}