2022-12-16 03:07:15 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, lib, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
testPort = 8888;
|
|
|
|
testUser = "testerman";
|
|
|
|
testPass = "password";
|
|
|
|
testEmail = "test.testerman@test.com";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
name = "atuin";
|
2023-04-30 14:26:15 +00:00
|
|
|
meta.maintainers = with lib.maintainers; [ devusb ];
|
2022-12-16 03:07:15 +00:00
|
|
|
|
|
|
|
nodes = {
|
|
|
|
server =
|
|
|
|
{ ... }:
|
|
|
|
{
|
2023-07-26 20:20:53 +00:00
|
|
|
services.postgresql.enable = true;
|
|
|
|
|
2022-12-16 03:07:15 +00:00
|
|
|
services.atuin = {
|
|
|
|
enable = true;
|
|
|
|
port = testPort;
|
|
|
|
host = "0.0.0.0";
|
|
|
|
openFirewall = true;
|
|
|
|
openRegistration = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
client =
|
|
|
|
{ ... }:
|
|
|
|
{ };
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = with pkgs; ''
|
|
|
|
start_all()
|
|
|
|
|
|
|
|
# wait for atuin server startup
|
|
|
|
server.wait_for_unit("atuin.service")
|
|
|
|
server.wait_for_open_port(${toString testPort})
|
|
|
|
|
|
|
|
# configure atuin client on server node
|
|
|
|
server.execute("mkdir -p ~/.config/atuin")
|
|
|
|
server.execute("echo 'sync_address = \"http://localhost:${toString testPort}\"' > ~/.config/atuin/config.toml")
|
|
|
|
|
|
|
|
# register with atuin server on server node
|
|
|
|
server.succeed("${atuin}/bin/atuin register -u ${testUser} -p ${testPass} -e ${testEmail}")
|
|
|
|
_, key = server.execute("${atuin}/bin/atuin key")
|
|
|
|
|
|
|
|
# store test record in atuin server and sync
|
|
|
|
server.succeed("ATUIN_SESSION=$(${atuin}/bin/atuin uuid) ${atuin}/bin/atuin history start 'shazbot'")
|
|
|
|
server.succeed("${atuin}/bin/atuin sync")
|
|
|
|
|
|
|
|
# configure atuin client on client node
|
|
|
|
client.execute("mkdir -p ~/.config/atuin")
|
|
|
|
client.execute("echo 'sync_address = \"http://server:${toString testPort}\"' > ~/.config/atuin/config.toml")
|
|
|
|
|
|
|
|
# log in to atuin server on client node
|
2023-03-02 17:23:50 +00:00
|
|
|
client.succeed(f"${atuin}/bin/atuin login -u ${testUser} -p ${testPass} -k \"{key}\"")
|
2022-12-16 03:07:15 +00:00
|
|
|
|
|
|
|
# pull records from atuin server
|
|
|
|
client.succeed("${atuin}/bin/atuin sync -f")
|
|
|
|
|
|
|
|
# check for test record
|
|
|
|
client.succeed("ATUIN_SESSION=$(${atuin}/bin/atuin uuid) ${atuin}/bin/atuin history list | grep shazbot")
|
|
|
|
'';
|
|
|
|
})
|