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 <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: adisbladis <adisbladis@gmail.com>
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
Florian Klink 2023-09-10 12:40:13 +02:00 committed by clbot
parent 6fa80ecc3d
commit 9786255267

View file

@ -1,4 +1,4 @@
{ depot, config, ... }: { depot, pkgs, config, ... }:
{ {
imports = [ imports = [
@ -20,6 +20,16 @@
alias ${depot.tvix.docs.svg}/component-flow.svg; alias ${depot.tvix.docs.svg}/component-flow.svg;
} }
location = /go-get/tvix/store/protos {
alias ${pkgs.writeText "go-import-metadata.html" ''<html><meta name="go-import" content="code.tvl.fyi/tvix/store/protos git https://code.tvl.fyi/depot.git:/tvix/store/protos.git"></html>''};
}
location = /tvix/store/protos {
if ($args ~* "/?go-get=1") {
return 302 /go-get/tvix/store/protos;
}
}
# Git operations on depot.git hit josh # Git operations on depot.git hit josh
location /depot.git { location /depot.git {
proxy_pass http://localhost:${toString config.services.depot.josh.port}; proxy_pass http://localhost:${toString config.services.depot.josh.port};