From 9786255267671f5a8f1ed856d938283139ccf41d Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sun, 10 Sep 2023 12:40:13 +0200 Subject: feat(ops/modules/code.tvl.fyi): fix go get for tvix store protos There's a go.mod in in tvix/store/protos, which sets the module path to code.tvl.fyi/tvix/store/protos. While this path makes kinda sense, it's currently not possible to `go get` it from that location, as we serve the cgit interface from there. Fortunately, `go get` has a mechanism to determine clone URLs for a given go module path, as documented in https://go.dev/ref/mod#vcs-find. We simply need to serve a small HTML file at that path, describing the proper clone URL. This points the clone URL for code.tvl.fyi/tvix/store/protos to a josh- provided subtree of just :/tvix/store/protos, which will contain the root go.mod file. We need another layer of indirection as nginx can't have an `alias` directive inside a conditional block (but can have a redirect). Contrary to https://b.tvl.fyi/issues/299#comment-464, it seems to work for our usecase. It might become a problem if we actually serve `go.mod` files in a nested fashion at some point, but let's look at that once we get there. Fixes b/299. Change-Id: Idcad795105af5d57e6d06de6e232881dccf9110b Reviewed-on: https://cl.tvl.fyi/c/depot/+/9290 Autosubmit: flokli Tested-by: BuildkiteCI Reviewed-by: adisbladis Reviewed-by: tazjin --- ops/modules/www/code.tvl.fyi.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'ops/modules/www') diff --git a/ops/modules/www/code.tvl.fyi.nix b/ops/modules/www/code.tvl.fyi.nix index 3f34a9422c..5a7a9193ae 100644 --- a/ops/modules/www/code.tvl.fyi.nix +++ b/ops/modules/www/code.tvl.fyi.nix @@ -1,4 +1,4 @@ -{ depot, config, ... }: +{ depot, pkgs, config, ... }: { imports = [ @@ -20,6 +20,16 @@ alias ${depot.tvix.docs.svg}/component-flow.svg; } + location = /go-get/tvix/store/protos { + alias ${pkgs.writeText "go-import-metadata.html" ''''}; + } + + location = /tvix/store/protos { + if ($args ~* "/?go-get=1") { + return 302 /go-get/tvix/store/protos; + } + } + # Git operations on depot.git hit josh location /depot.git { proxy_pass http://localhost:${toString config.services.depot.josh.port}; -- cgit 1.4.1