From 820e98fa7fad2b67bd6a00af9aec068342321873 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 12 Apr 2024 20:27:15 +0300 Subject: refactor(tvix/boot): use tvix-store copy Instead of using an additional Nix build producing a directory structure containing xz-compressed NAR files and NARInfos, and uploading these via `curl` to NAR-bridge, which then decomposes them and uploads them to tvix-store, have tvix-store interpret the exported reference graph directly, and deal with the uploading on its own. Change-Id: I44ee0b132944c53d11abb688d2d017f0cc9c3d97 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11398 Reviewed-by: raitobezarius Autosubmit: flokli Tested-by: BuildkiteCI --- tvix/boot/tests/default.nix | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/tvix/boot/tests/default.nix b/tvix/boot/tests/default.nix index 108803d7ab..949be35ccf 100644 --- a/tvix/boot/tests/default.nix +++ b/tvix/boot/tests/default.nix @@ -32,14 +32,12 @@ let pkgs.stdenv.mkDerivation { name = "run-vm"; + __structuredAttrs = true; + exportReferencesGraph.closure = [ path ]; + nativeBuildInputs = [ depot.tvix.store depot.tvix.boot.runVM - ] ++ lib.optionals isClosure [ - depot.tvix.nar-bridge - pkgs.curl - pkgs.parallel - pkgs.xz.bin ]; buildCommand = '' touch $out @@ -67,34 +65,9 @@ let echo "imported to $outpath" '' + lib.optionalString (isClosure) '' - echo "Starting nar-bridge…" - nar-bridge-http \ - --otlp=false \ - --store-addr=unix://$PWD/tvix-store.sock \ - --listen-addr=$PWD/nar-bridge.sock & - - # Wait for the socket to be created. - while [ ! -e $PWD/nar-bridge.sock ]; do sleep 1; done - - # Upload. We can't use nix copy --to http://…, as it wants access to the nix db. - # However, we can use mkBinaryCache to assemble .narinfo and .nar.xz to upload, - # and then drive a HTTP client ourselves. - to_upload=${pkgs.mkBinaryCache { rootPaths = [path];}} - - # Upload all NAR files (with some parallelism). - # As mkBinaryCache produces them xz-compressed, unpack them on the fly. - # nar-bridge doesn't care about the path we upload *to*, but a - # subsequent .narinfo upload need to refer to its contents (by narhash). - echo -e "Uploading NARs… " - ls -d $to_upload/nar/*.nar.xz | parallel 'xz -d < {} | curl -s -T - --unix-socket $PWD/nar-bridge.sock http://localhost:9000/nar/$(basename {} | cut -d "." -f 1).nar' - echo "Done." - - # Upload all NARInfo files. - # FUTUREWORK: This doesn't upload them in order, and currently relies - # on PathInfoService not doing any checking. - # In the future, we might want to make this behaviour configurable, - # and disable checking here, to keep the logic simple. - ls -d $to_upload/*.narinfo | parallel 'curl -s -T - --unix-socket $PWD/nar-bridge.sock http://localhost:9000/$(basename {}) < {}' + echo "Copying closure ${path}…" + # This picks up the `closure` key in `$NIX_ATTRS_JSON_FILE` automatically. + tvix-store --otlp=false copy '' + '' # Invoke a VM using tvix as the backing store, ensure the outpath appears in its listing. -- cgit 1.4.1