about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--nix/bufCheck/default.nix1
-rw-r--r--ops/modules/www/code.tvl.fyi.nix2
-rw-r--r--tvix/castore-go/LICENSE21
-rw-r--r--tvix/castore-go/README.md10
-rw-r--r--tvix/castore-go/castore.go (renamed from tvix/castore/protos/castore.go)0
-rw-r--r--tvix/castore-go/castore.pb.go (renamed from tvix/castore/protos/castore.pb.go)0
-rw-r--r--tvix/castore-go/castore_test.go (renamed from tvix/castore/protos/castore_test.go)0
-rw-r--r--tvix/castore-go/default.nix25
-rw-r--r--tvix/castore-go/go.mod (renamed from tvix/castore/protos/go.mod)0
-rw-r--r--tvix/castore-go/go.sum (renamed from tvix/castore/protos/go.sum)0
-rw-r--r--tvix/castore-go/rename_node.go (renamed from tvix/castore/protos/rename_node.go)0
-rw-r--r--tvix/castore-go/rpc_blobstore.pb.go (renamed from tvix/castore/protos/rpc_blobstore.pb.go)0
-rw-r--r--tvix/castore-go/rpc_blobstore_grpc.pb.go (renamed from tvix/castore/protos/rpc_blobstore_grpc.pb.go)0
-rw-r--r--tvix/castore-go/rpc_directory.pb.go (renamed from tvix/castore/protos/rpc_directory.pb.go)0
-rw-r--r--tvix/castore-go/rpc_directory_grpc.pb.go (renamed from tvix/castore/protos/rpc_directory_grpc.pb.go)0
-rw-r--r--tvix/castore/protos/default.nix33
-rw-r--r--tvix/default.nix11
17 files changed, 94 insertions, 9 deletions
diff --git a/nix/bufCheck/default.nix b/nix/bufCheck/default.nix
index 3a645133049a..f247e6839eee 100644
--- a/nix/bufCheck/default.nix
+++ b/nix/bufCheck/default.nix
@@ -7,7 +7,6 @@ pkgs.writeShellScriptBin "ci-buf-check" ''
   (cd $(git rev-parse --show-toplevel) && buf lint .)
 
   # Run buf generate, and bail out if generated files are changed.
-  (cd $(git rev-parse --show-toplevel) && buf generate --path tvix/castore/protos)
   (cd $(git rev-parse --show-toplevel) && buf generate --path tvix/store/protos)
   # Check if any files have changed
   if [[ -n "$(git status --porcelain -unormal)" ]]; then
diff --git a/ops/modules/www/code.tvl.fyi.nix b/ops/modules/www/code.tvl.fyi.nix
index 8d8938bcaef6..6a7e4b25038a 100644
--- a/ops/modules/www/code.tvl.fyi.nix
+++ b/ops/modules/www/code.tvl.fyi.nix
@@ -21,7 +21,7 @@
         }
 
         location = /go-get/tvix/castore/protos {
-            alias ${pkgs.writeText "go-import-metadata.html" ''<html><meta name="go-import" content="code.tvl.fyi/tvix/castore/protos git https://code.tvl.fyi/depot.git:/tvix/castore/protos.git"></html>''};
+            alias ${pkgs.writeText "go-import-metadata.html" ''<html><meta name="go-import" content="code.tvl.fyi/tvix/castore/protos git https://code.tvl.fyi/depot.git:/tvix/castore-go.git"></html>''};
         }
 
         location = /go-get/tvix/store/protos {
diff --git a/tvix/castore-go/LICENSE b/tvix/castore-go/LICENSE
new file mode 100644
index 000000000000..2034ada6fd9a
--- /dev/null
+++ b/tvix/castore-go/LICENSE
@@ -0,0 +1,21 @@
+Copyright © The Tvix Authors
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+“Software”), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/tvix/castore-go/README.md b/tvix/castore-go/README.md
new file mode 100644
index 000000000000..1aee48dfdf39
--- /dev/null
+++ b/tvix/castore-go/README.md
@@ -0,0 +1,10 @@
+# castore-go
+
+This directory contains generated golang bindings, both for the `tvix-castore`
+data models, as well as the gRPC bindings.
+
+They are generated with `mg run //tvix:castore-go-generate`.
+These files end with `.pb.go`, and are ensured to be up to date by a CI check.
+
+Additionally, code useful when interacting with these data structures
+(ending just with `.go`) is provided.
diff --git a/tvix/castore/protos/castore.go b/tvix/castore-go/castore.go
index c9e3757885a0..c9e3757885a0 100644
--- a/tvix/castore/protos/castore.go
+++ b/tvix/castore-go/castore.go
diff --git a/tvix/castore/protos/castore.pb.go b/tvix/castore-go/castore.pb.go
index 5323d6c923a8..5323d6c923a8 100644
--- a/tvix/castore/protos/castore.pb.go
+++ b/tvix/castore-go/castore.pb.go
diff --git a/tvix/castore/protos/castore_test.go b/tvix/castore-go/castore_test.go
index fda87a6cfb66..fda87a6cfb66 100644
--- a/tvix/castore/protos/castore_test.go
+++ b/tvix/castore-go/castore_test.go
diff --git a/tvix/castore-go/default.nix b/tvix/castore-go/default.nix
new file mode 100644
index 000000000000..09bbb77f81d4
--- /dev/null
+++ b/tvix/castore-go/default.nix
@@ -0,0 +1,25 @@
+{ depot, pkgs, ... }:
+
+(pkgs.buildGoModule {
+  name = "castore-go";
+  src = depot.third_party.gitignoreSource ./.;
+  vendorHash = "sha256-ZNtSSW+oCxMsBtURSrea9/GyUHDagtGefM+Ii+VkgCA=";
+}).overrideAttrs (_: {
+  meta.ci.extraSteps = {
+    check = {
+      label = ":water_buffalo: ensure generated protobuf files match";
+      needsOutput = true;
+      command = pkgs.writeShellScript "pb-go-check" ''
+        ${depot.tvix.castore-go-generate}
+        if [[ -n "$(git status --porcelain -unormal)" ]]; then
+            echo "-----------------------------"
+            echo ".pb.go files need to be updated, run //tvix:castore-go-generate"
+            echo "-----------------------------"
+            git status -unormal
+            exit 1
+        fi
+      '';
+      alwaysRun = true;
+    };
+  };
+})
diff --git a/tvix/castore/protos/go.mod b/tvix/castore-go/go.mod
index 9048aa205c46..9048aa205c46 100644
--- a/tvix/castore/protos/go.mod
+++ b/tvix/castore-go/go.mod
diff --git a/tvix/castore/protos/go.sum b/tvix/castore-go/go.sum
index 535b8e32f063..535b8e32f063 100644
--- a/tvix/castore/protos/go.sum
+++ b/tvix/castore-go/go.sum
diff --git a/tvix/castore/protos/rename_node.go b/tvix/castore-go/rename_node.go
index 80537b16d38d..80537b16d38d 100644
--- a/tvix/castore/protos/rename_node.go
+++ b/tvix/castore-go/rename_node.go
diff --git a/tvix/castore/protos/rpc_blobstore.pb.go b/tvix/castore-go/rpc_blobstore.pb.go
index 1afc82674451..1afc82674451 100644
--- a/tvix/castore/protos/rpc_blobstore.pb.go
+++ b/tvix/castore-go/rpc_blobstore.pb.go
diff --git a/tvix/castore/protos/rpc_blobstore_grpc.pb.go b/tvix/castore-go/rpc_blobstore_grpc.pb.go
index 0876bcc4e95a..0876bcc4e95a 100644
--- a/tvix/castore/protos/rpc_blobstore_grpc.pb.go
+++ b/tvix/castore-go/rpc_blobstore_grpc.pb.go
diff --git a/tvix/castore/protos/rpc_directory.pb.go b/tvix/castore-go/rpc_directory.pb.go
index f658c6b60cc0..f658c6b60cc0 100644
--- a/tvix/castore/protos/rpc_directory.pb.go
+++ b/tvix/castore-go/rpc_directory.pb.go
diff --git a/tvix/castore/protos/rpc_directory_grpc.pb.go b/tvix/castore-go/rpc_directory_grpc.pb.go
index f19e457d867b..f19e457d867b 100644
--- a/tvix/castore/protos/rpc_directory_grpc.pb.go
+++ b/tvix/castore-go/rpc_directory_grpc.pb.go
diff --git a/tvix/castore/protos/default.nix b/tvix/castore/protos/default.nix
new file mode 100644
index 000000000000..e2e2f910ee51
--- /dev/null
+++ b/tvix/castore/protos/default.nix
@@ -0,0 +1,33 @@
+{ depot, pkgs, ... }: {
+  # Produces the golang bindings.
+  go-bindings = pkgs.stdenv.mkDerivation {
+    name = "go-bindings";
+
+    src = depot.nix.sparseTree {
+      name = "castore-protos";
+      root = depot.path.origSrc;
+      paths = [
+        ./castore.proto
+        ./rpc_blobstore.proto
+        ./rpc_directory.proto
+        ../../../buf.yaml
+        ../../../buf.gen.yaml
+      ];
+    };
+
+    nativeBuildInputs = [
+      pkgs.buf
+      pkgs.protoc-gen-go
+      pkgs.protoc-gen-go-grpc
+    ];
+
+    buildPhase = ''
+      export HOME=$TMPDIR
+      buf lint
+      buf generate
+
+      mkdir -p $out
+      cp tvix/castore/protos/*.pb.go $out/
+    '';
+  };
+}
diff --git a/tvix/default.nix b/tvix/default.nix
index dfb9f414373a..3365fe79812e 100644
--- a/tvix/default.nix
+++ b/tvix/default.nix
@@ -106,12 +106,10 @@ in
   # workspace too.
   shell = (import ./shell.nix { inherit pkgs; });
 
-  # Builds and tests the code in castore/protos.
-  castore-protos-go = pkgs.buildGoModule {
-    name = "castore-golang";
-    src = depot.third_party.gitignoreSource ./castore/protos;
-    vendorHash = "sha256-ZNtSSW+oCxMsBtURSrea9/GyUHDagtGefM+Ii+VkgCA=";
-  };
+  # Update `.pb.go` files in tvix/castore-go with the generated ones.
+  castore-go-generate = pkgs.writeShellScriptBin "castore-go-protogen" ''
+    (cd $(git rev-parse --show-toplevel)/tvix/castore-go && rm *.pb.go && cp ${depot.tvix.castore.protos.go-bindings}/*.pb.go . && chmod +w *.pb.go)
+  '';
 
   # Builds and tests the code in store/protos.
   store-protos-go = pkgs.buildGoModule {
@@ -146,7 +144,6 @@ in
   };
 
   meta.ci.targets = [
-    "castore-protos-go"
     "store-protos-go"
     "shell"
     "rust-docs"