1{ lib, ... }:
2
3let
4 testPort = 8888;
5 testUser = "testerman";
6 testPass = "password";
7 testEmail = "test.testerman@test.com";
8in
9{
10 name = "atuin";
11 meta.maintainers = with lib.maintainers; [ devusb ];
12
13 defaults =
14 { pkgs, ... }:
15 {
16 environment.systemPackages = [
17 pkgs.atuin
18 ];
19 };
20
21 nodes = {
22 server =
23 { ... }:
24 {
25 services.postgresql.enable = true;
26
27 services.atuin = {
28 enable = true;
29 port = testPort;
30 host = "0.0.0.0";
31 openFirewall = true;
32 openRegistration = true;
33 };
34 };
35
36 client = { ... }: { };
37
38 };
39
40 testScript =
41 { nodes, ... }:
42 #python
43 ''
44 start_all()
45
46 # wait for atuin server startup
47 server.wait_for_unit("atuin.service")
48 server.wait_for_open_port(${toString testPort})
49
50 # configure atuin client on server node
51 server.execute("mkdir -p ~/.config/atuin")
52 server.execute("echo 'sync_address = \"http://localhost:${toString testPort}\"' > ~/.config/atuin/config.toml")
53
54 # register with atuin server on server node
55 server.succeed("atuin register -u ${testUser} -p ${testPass} -e ${testEmail}")
56 _, key = server.execute("atuin key")
57
58 # store test record in atuin server and sync
59 server.succeed("ATUIN_SESSION=$(atuin uuid) atuin history start 'shazbot'")
60 server.succeed("ATUIN_SESSION=$(atuin uuid) atuin sync")
61
62 # configure atuin client on client node
63 client.execute("mkdir -p ~/.config/atuin")
64 client.execute("echo 'sync_address = \"http://server:${toString testPort}\"' > ~/.config/atuin/config.toml")
65
66 # log in to atuin server on client node
67 client.succeed(f"atuin login -u ${testUser} -p ${testPass} -k \"{key}\"")
68
69 # pull records from atuin server
70 client.succeed("atuin sync -f")
71
72 # check for test record
73 client.succeed("ATUIN_SESSION=$(atuin uuid) atuin history list | grep shazbot")
74 '';
75}