diff --git a/nix/bufCheck/default.nix b/nix/bufCheck/default.nix
index f247e6839..90c0ca3cb 100644
--- a/nix/bufCheck/default.nix
+++ b/nix/bufCheck/default.nix
@@ -6,8 +6,6 @@ pkgs.writeShellScriptBin "ci-buf-check" ''
export PATH="$PATH:${pkgs.lib.makeBinPath [ pkgs.buf pkgs.protoc-gen-go pkgs.protoc-gen-go-grpc ]}"
(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/store/protos)
# Check if any files have changed
if [[ -n "$(git status --porcelain -unormal)" ]]; then
echo "-----------------------------"
diff --git a/ops/modules/www/code.tvl.fyi.nix b/ops/modules/www/code.tvl.fyi.nix
index 6a7e4b250..b64f8f8ce 100644
--- a/ops/modules/www/code.tvl.fyi.nix
+++ b/ops/modules/www/code.tvl.fyi.nix
@@ -25,7 +25,7 @@
}
location = /go-get/tvix/store/protos {
- alias ${pkgs.writeText "go-import-metadata.html" ''''};
+ alias ${pkgs.writeText "go-import-metadata.html" ''''};
}
location = /go-get/tvix/nar-bridge {
diff --git a/tvix/default.nix b/tvix/default.nix
index 3365fe798..28e64d574 100644
--- a/tvix/default.nix
+++ b/tvix/default.nix
@@ -111,12 +111,10 @@ in
(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 {
- name = "store-golang";
- src = depot.third_party.gitignoreSource ./store/protos;
- vendorHash = "sha256-WAYaIT3h3Cdvo1RB8T7DuoxeKvXfkq8vo/vdkhJQDs0=";
- };
+ # Update `.pb.go` files in tvix/store-go with the generated ones.
+ store-go-generate = pkgs.writeShellScriptBin "store-go-protogen" ''
+ (cd $(git rev-parse --show-toplevel)/tvix/store-go && rm *.pb.go && cp ${depot.tvix.store.protos.go-bindings}/*.pb.go . && chmod +w *.pb.go)
+ '';
# Build the Rust documentation for publishing on docs.tvix.dev.
rust-docs = pkgs.stdenv.mkDerivation {
@@ -144,7 +142,6 @@ in
};
meta.ci.targets = [
- "store-protos-go"
"shell"
"rust-docs"
];
diff --git a/tvix/store-go/LICENSE b/tvix/store-go/LICENSE
new file mode 100644
index 000000000..2034ada6f
--- /dev/null
+++ b/tvix/store-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/store-go/README.md b/tvix/store-go/README.md
new file mode 100644
index 000000000..4cfa55a35
--- /dev/null
+++ b/tvix/store-go/README.md
@@ -0,0 +1,10 @@
+# store-go
+
+This directory contains generated golang bindings, both for the tvix-store data
+models, as well as the gRPC bindings.
+
+They are generated with `mg run //tvix:store-go-generate`.
+These files end with `.pb.go`, and are ensured to be up to date by Ci check.
+
+Additionally, code useful when interacting with these data structures
+(ending just with `.go`) is provided.
\ No newline at end of file
diff --git a/tvix/store-go/default.nix b/tvix/store-go/default.nix
new file mode 100644
index 000000000..b559594a2
--- /dev/null
+++ b/tvix/store-go/default.nix
@@ -0,0 +1,25 @@
+{ depot, pkgs, ... }:
+
+(pkgs.buildGoModule {
+ name = "store-go";
+ src = depot.third_party.gitignoreSource ./.;
+ vendorHash = "sha256-WAYaIT3h3Cdvo1RB8T7DuoxeKvXfkq8vo/vdkhJQDs0=";
+}).overrideAttrs (_: {
+ meta.ci.extraSteps = {
+ check = {
+ label = ":water_buffalo: ensure generated protobuf files match";
+ needsOutput = true;
+ command = pkgs.writeShellScript "pb-go-check" ''
+ ${depot.tvix.store-go-generate}
+ if [[ -n "$(git status --porcelain -unormal)" ]]; then
+ echo "-----------------------------"
+ echo ".pb.go files need to be updated, run //tvix:store-go-generate"
+ echo "-----------------------------"
+ git status -unormal
+ exit 1
+ fi
+ '';
+ alwaysRun = true;
+ };
+ };
+})
diff --git a/tvix/store/protos/export.go b/tvix/store-go/export.go
similarity index 100%
rename from tvix/store/protos/export.go
rename to tvix/store-go/export.go
diff --git a/tvix/store/protos/export_test.go b/tvix/store-go/export_test.go
similarity index 100%
rename from tvix/store/protos/export_test.go
rename to tvix/store-go/export_test.go
diff --git a/tvix/store/protos/go.mod b/tvix/store-go/go.mod
similarity index 100%
rename from tvix/store/protos/go.mod
rename to tvix/store-go/go.mod
diff --git a/tvix/store/protos/go.sum b/tvix/store-go/go.sum
similarity index 100%
rename from tvix/store/protos/go.sum
rename to tvix/store-go/go.sum
diff --git a/tvix/store/protos/pathinfo.go b/tvix/store-go/pathinfo.go
similarity index 100%
rename from tvix/store/protos/pathinfo.go
rename to tvix/store-go/pathinfo.go
diff --git a/tvix/store/protos/pathinfo.pb.go b/tvix/store-go/pathinfo.pb.go
similarity index 100%
rename from tvix/store/protos/pathinfo.pb.go
rename to tvix/store-go/pathinfo.pb.go
diff --git a/tvix/store/protos/pathinfo_test.go b/tvix/store-go/pathinfo_test.go
similarity index 100%
rename from tvix/store/protos/pathinfo_test.go
rename to tvix/store-go/pathinfo_test.go
diff --git a/tvix/store/protos/pick_next_node_test.go b/tvix/store-go/pick_next_node_test.go
similarity index 100%
rename from tvix/store/protos/pick_next_node_test.go
rename to tvix/store-go/pick_next_node_test.go
diff --git a/tvix/store/protos/rpc_pathinfo.pb.go b/tvix/store-go/rpc_pathinfo.pb.go
similarity index 100%
rename from tvix/store/protos/rpc_pathinfo.pb.go
rename to tvix/store-go/rpc_pathinfo.pb.go
diff --git a/tvix/store/protos/rpc_pathinfo_grpc.pb.go b/tvix/store-go/rpc_pathinfo_grpc.pb.go
similarity index 100%
rename from tvix/store/protos/rpc_pathinfo_grpc.pb.go
rename to tvix/store-go/rpc_pathinfo_grpc.pb.go
diff --git a/tvix/store/protos/testdata/emptydirectory.nar b/tvix/store-go/testdata/emptydirectory.nar
similarity index 100%
rename from tvix/store/protos/testdata/emptydirectory.nar
rename to tvix/store-go/testdata/emptydirectory.nar
diff --git a/tvix/store/protos/testdata/onebyteregular.nar b/tvix/store-go/testdata/onebyteregular.nar
similarity index 100%
rename from tvix/store/protos/testdata/onebyteregular.nar
rename to tvix/store-go/testdata/onebyteregular.nar
diff --git a/tvix/store/protos/testdata/symlink.nar b/tvix/store-go/testdata/symlink.nar
similarity index 100%
rename from tvix/store/protos/testdata/symlink.nar
rename to tvix/store-go/testdata/symlink.nar
diff --git a/tvix/store/protos/default.nix b/tvix/store/protos/default.nix
new file mode 100644
index 000000000..5f56eda79
--- /dev/null
+++ b/tvix/store/protos/default.nix
@@ -0,0 +1,34 @@
+{ 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 = [
+ # We need to include castore.proto (only), as it's referred.
+ ../../castore/protos/castore.proto
+ ./pathinfo.proto
+ ./rpc_pathinfo.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/store/protos/*.pb.go $out/
+ '';
+ };
+}