about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-04-12T17·27+0300
committerclbot <clbot@tvl.fyi>2024-04-13T10·44+0000
commit820e98fa7fad2b67bd6a00af9aec068342321873 (patch)
tree10ddd3efa948c98e90d457db6d8066894ebf2eb0
parenta4f65ddba06f1170905f7f0ea03616bd690b13d0 (diff)
refactor(tvix/boot): use tvix-store copy r/7901
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 <tvl@lahfa.xyz>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
-rw-r--r--tvix/boot/tests/default.nix39
1 files 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.