about summary refs log tree commit diff
path: root/nixos/tests/livebook-service.nix
blob: f428412e16448cce113596717ed62e6c5434b172 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import ./make-test-python.nix ({ lib, pkgs, ... }: {
  name = "livebook-service";

  nodes = {
    machine = { config, pkgs, ... }: {
      imports = [
        ./common/user-account.nix
      ];

      services.livebook = {
        enableUserService = true;
        environment = {
          LIVEBOOK_PORT = 20123;
          LIVEBOOK_COOKIE = "chocolate chip";
          LIVEBOOK_TOKEN_ENABLED = true;

        };
        environmentFile = pkgs.writeText "livebook.env" ''
          LIVEBOOK_PASSWORD = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        '';
      };
    };
  };

  testScript = { nodes, ... }:
    let
      user = nodes.machine.users.users.alice;
      sudo = lib.concatStringsSep " " [
        "XDG_RUNTIME_DIR=/run/user/${toString user.uid}"
        "sudo"
        "--preserve-env=XDG_RUNTIME_DIR"
        "-u"
        "alice"
      ];
    in
    ''
      machine.wait_for_unit("multi-user.target")

      machine.succeed("loginctl enable-linger alice")
      machine.wait_until_succeeds("${sudo} systemctl --user is-active livebook.service")
      machine.wait_for_open_port(20123)

      machine.succeed("curl -L localhost:20123 | grep 'Type password'")
    '';
})