2024-03-17 21:00:44 +01:00
|
|
|
{ depot, pkgs, lib, ... }:
|
2023-09-25 12:59:25 +02:00
|
|
|
|
2024-03-11 23:07:46 +01:00
|
|
|
let
|
2023-09-25 12:59:25 +02:00
|
|
|
# Seed a tvix-store with the tvix docs, then start a VM, ask it to list all
|
|
|
|
# files in /nix/store, and ensure the store path is present, which acts as a
|
|
|
|
# nice smoketest.
|
2024-03-17 21:00:44 +01:00
|
|
|
mkBootTest =
|
|
|
|
{ blobServiceAddr ? "memory://"
|
|
|
|
, directoryServiceAddr ? "memory://"
|
|
|
|
, pathInfoServiceAddr ? "memory://"
|
|
|
|
# The path to import (via tvix-store import).
|
|
|
|
, importPath ? ../../docs
|
|
|
|
, importPathName ? "docs"
|
|
|
|
}:
|
2024-03-11 23:07:46 +01:00
|
|
|
pkgs.stdenv.mkDerivation {
|
|
|
|
name = "run-vm";
|
|
|
|
nativeBuildInputs = [
|
|
|
|
depot.tvix.store
|
|
|
|
depot.tvix.boot.runVM
|
|
|
|
];
|
|
|
|
buildCommand = ''
|
|
|
|
touch $out
|
2023-09-25 12:59:25 +02:00
|
|
|
|
2024-03-17 21:00:44 +01:00
|
|
|
# Start the tvix daemon, listening on a unix socket.
|
|
|
|
BLOB_SERVICE_ADDR=${blobServiceAddr} \
|
|
|
|
DIRECTORY_SERVICE_ADDR=${directoryServiceAddr} \
|
|
|
|
PATH_INFO_SERVICE_ADDR=${pathInfoServiceAddr} \
|
|
|
|
tvix-store daemon -l $PWD/tvix-store.socket &
|
2023-09-25 12:59:25 +02:00
|
|
|
|
2024-03-17 21:00:44 +01:00
|
|
|
# Wait for the socket to be created.
|
|
|
|
while [ ! -e $PWD/tvix-store.socket ]; do sleep 1; done
|
2023-09-25 12:59:25 +02:00
|
|
|
|
2024-03-17 21:00:44 +01:00
|
|
|
# Export env vars so that subsequent tvix-store commands will talk to
|
|
|
|
# our tvix-store daemon over the unix socket.
|
|
|
|
export BLOB_SERVICE_ADDR=grpc+unix://$PWD/tvix-store.socket
|
|
|
|
export DIRECTORY_SERVICE_ADDR=grpc+unix://$PWD/tvix-store.socket
|
|
|
|
export PATH_INFO_SERVICE_ADDR=grpc+unix://$PWD/tvix-store.socket
|
|
|
|
'' + lib.optionalString (importPath != null) ''
|
|
|
|
echo "Importing ${importPath} into tvix-store with name ${importPathName}…"
|
|
|
|
cp -R ${importPath} ${importPathName}
|
|
|
|
outpath=$(tvix-store import ${importPathName})
|
|
|
|
|
|
|
|
echo "imported to $outpath"
|
|
|
|
|
|
|
|
# Invoke a VM using tvix as the backing store, ensure the outpath appears in its listing.
|
2023-09-25 12:59:25 +02:00
|
|
|
|
2024-03-11 23:07:46 +01:00
|
|
|
CH_CMDLINE="tvix.find" run-tvix-vm 2>&1 | tee output.txt
|
2024-03-17 21:00:44 +01:00
|
|
|
grep $outpath output.txt
|
2024-03-11 23:07:46 +01:00
|
|
|
'';
|
|
|
|
requiredSystemFeatures = [ "kvm" ];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
depot.nix.readTree.drvTargets {
|
2024-03-17 21:00:44 +01:00
|
|
|
docs-memory = (mkBootTest { });
|
|
|
|
docs-sled = (mkBootTest {
|
|
|
|
blobServiceAddr = "sled://$PWD/blobs.sled";
|
|
|
|
directoryServiceAddr = "sled://$PWD/directories.sled";
|
|
|
|
pathInfoServiceAddr = "sled://$PWD/pathinfo.sled";
|
|
|
|
});
|
|
|
|
docs-objectstore-local = (mkBootTest {
|
|
|
|
blobServiceAddr = "objectstore+file://$PWD/blobs";
|
|
|
|
});
|
2023-09-25 12:59:25 +02:00
|
|
|
}
|