2024-08-23 12:09:03 +02:00
|
|
|
# This configuration redirects from the previous Sourcegraph instance to
|
|
|
|
# livegrep/cgit where appropriate.
|
2020-07-12 13:54:16 +02:00
|
|
|
{ config, ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
./base.nix
|
|
|
|
];
|
|
|
|
|
|
|
|
config = {
|
|
|
|
services.nginx.virtualHosts."cs.tvl.fyi" = {
|
|
|
|
serverName = "cs.tvl.fyi";
|
2021-04-02 12:52:55 +02:00
|
|
|
serverAliases = [ "cs.tvl.su" ];
|
2020-07-12 13:54:16 +02:00
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
|
|
|
|
extraConfig = ''
|
2024-08-23 12:09:03 +02:00
|
|
|
set $lineno "";
|
|
|
|
|
|
|
|
# depot root
|
|
|
|
location = /depot {
|
|
|
|
return 301 https://code.tvl.fyi/tree/;
|
2020-07-12 13:54:16 +02:00
|
|
|
}
|
|
|
|
|
2024-08-23 12:09:03 +02:00
|
|
|
# folder/file on canon
|
|
|
|
location ~ ^/depot/-/(blob|tree)/([^\s]*)$ {
|
|
|
|
set $path $2;
|
|
|
|
if ($args ~ ^L(\d+)(-\d+)?$) {
|
|
|
|
set $lineno "#n$1";
|
|
|
|
}
|
|
|
|
|
|
|
|
return 302 https://code.tvl.fyi/tree/$path$lineno;
|
|
|
|
}
|
|
|
|
|
|
|
|
# folder/file on specific commit
|
|
|
|
location ~ ^/depot@([a-f0-9]+)/-/(blob|tree)/([^\s]*)$ {
|
|
|
|
set $commit $1;
|
|
|
|
set $path $3;
|
|
|
|
|
|
|
|
if ($args ~ ^L(\d+)(-\d+)?$) {
|
|
|
|
set $lineno "#n$1";
|
|
|
|
}
|
|
|
|
|
|
|
|
return 302 https://code.tvl.fyi/tree/$path?id=$commit$lineno;
|
|
|
|
}
|
|
|
|
|
|
|
|
# commit info
|
|
|
|
location ~ ^/depot/-/commit/([a-f0-9]+)$ {
|
|
|
|
set $commit $1;
|
|
|
|
return 302 https://code.tvl.fyi/commit/?id=$commit;
|
2020-07-12 13:54:16 +02:00
|
|
|
}
|
|
|
|
|
2024-08-23 12:09:03 +02:00
|
|
|
# search handler
|
|
|
|
# This only redirects to the new search, it doesn't try to parse and
|
|
|
|
# rewrite the query.
|
|
|
|
location /search {
|
|
|
|
return 302 https://grep.tvl.fyi/search;
|
|
|
|
}
|
|
|
|
|
|
|
|
location / {
|
|
|
|
return 404 "TVL code search has moved to grep.tvl.fyi and we could not figure out how to rewrite your query. Sorry!";
|
2020-07-12 13:54:16 +02:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|