aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2026-10-25 08:22:31 +0100
committerMartin Fischer <martin@push-f.com>2026-10-26 16:49:21 +0100
commit5246f75d05847fad4345ae81d2f05fd6ea90ee10 (patch)
tree080f81e3a11e3af3abcbe52ddd3bdbcd94edca82
parent31b28a7c23825385f1f2990dbaa810264079af5a (diff)
refactor(tente): host geopos under geopos.push-f.com
-rw-r--r--nixos/hosts/tente/default.nix9
-rw-r--r--nixos/hosts/tente/git-web.nix49
-rw-r--r--nixos/npins/sources.json8
3 files changed, 45 insertions, 21 deletions
diff --git a/nixos/hosts/tente/default.nix b/nixos/hosts/tente/default.nix
index 5e7b278..82d58bb 100644
--- a/nixos/hosts/tente/default.nix
+++ b/nixos/hosts/tente/default.nix
@@ -30,7 +30,7 @@ in
"${sources.my-git-grep-exporter}/service.nix"
"${sources.my-lex-surf}/service.nix"
"${sources.my-osm-proposals}/service.nix"
- "${sources.my-geopos-link}/service.nix"
+ "${sources.my-geopos}/service.nix"
"${sources.my-rust-features}/service.nix"
"${sources.my-spec-pub}/service.nix"
"${sources.my-web-feed-exporter}/service.nix"
@@ -152,11 +152,14 @@ in
reposDir = reposDir;
user = "cgit";
group = "cgit";
+ repoRedirects = {
+ "geopos.link" = "geopos";
+ };
};
- services.geopos-share =
+ services.geopos =
let
- domain = "geopos.link";
+ domain = "geopos.${baseDomain}";
in
{
enable = true;
diff --git a/nixos/hosts/tente/git-web.nix b/nixos/hosts/tente/git-web.nix
index 9e8063c..a7d0fa1 100644
--- a/nixos/hosts/tente/git-web.nix
+++ b/nixos/hosts/tente/git-web.nix
@@ -18,6 +18,17 @@ in
group = lib.mkOption {
type = lib.types.str;
};
+ repoRedirects = lib.mkOption {
+ type = lib.types.attrsOf lib.types.str;
+ default = { };
+ example = {
+ old-name = "new-name";
+ };
+ description = ''
+ Mapping of old repository names to their new names. Requests for an old
+ repository and any paths below it are permanently redirected.
+ '';
+ };
};
config = {
@@ -32,22 +43,32 @@ in
# use fake browser user agents and hundreds of IP addresses.
# The number of possible URLs is O(commits x files), which can be a lot,
# so we guard the /<repo>/tree/<path>?id=<commit> endpoint with Basic Auth.
- locations."/".extraConfig =
- let
- cgitHtpasswd = pkgs.writeText "cgit.htpasswd" "guest:{PLAIN}\n";
- in
- ''
- set $auth off;
- # Unfortunately mainstream browsers don't display the realm anymore.
- set $realm "The username is guest, the password is blank.";
+ locations = {
+ "/".extraConfig =
+ let
+ cgitHtpasswd = pkgs.writeText "cgit.htpasswd" "guest:{PLAIN}\n";
+ in
+ ''
+ set $auth off;
+ # Unfortunately mainstream browsers don't display the realm anymore.
+ set $realm "The username is guest, the password is blank.";
- # We disallow /tree/ with URL query parameters.
- if ($request_uri ~ ^/[^/]+/tree(/[^?]*)?/?\?.+$) { set $auth $realm; }
- if ($request_uri ~ ^/[^/]+/diff(/|$|\?)) { set $auth $realm; }
+ # We disallow /tree/ with URL query parameters.
+ if ($request_uri ~ ^/[^/]+/tree(/[^?]*)?/?\?.+$) { set $auth $realm; }
+ if ($request_uri ~ ^/[^/]+/diff(/|$|\?)) { set $auth $realm; }
- auth_basic $auth;
- auth_basic_user_file ${cgitHtpasswd};
- '';
+ auth_basic $auth;
+ auth_basic_user_file ${cgitHtpasswd};
+ '';
+ }
+ // lib.mapAttrs' (
+ oldRepo: newRepo:
+ lib.nameValuePair "~ ^/${lib.escapeRegex oldRepo}(?<repoPath>/.*)?$" {
+ # This must precede cgit's regex location for git-http-backend.
+ priority = 500;
+ extraConfig = "return 301 /${newRepo}$repoPath$is_args$args;";
+ }
+ ) cfg.repoRedirects;
};
services.cgit.main = {
diff --git a/nixos/npins/sources.json b/nixos/npins/sources.json
index 8fc6e74..5d8be85 100644
--- a/nixos/npins/sources.json
+++ b/nixos/npins/sources.json
@@ -24,17 +24,17 @@
"url": null,
"hash": "sha256-EvMx0H72fWGHZK5tcfkV0KbmHEVY1G4eewCXCOBugCw="
},
- "my-geopos-link": {
+ "my-geopos": {
"type": "Git",
"repository": {
"type": "Git",
- "url": "https://git.push-f.com/geopos.link"
+ "url": "https://git.push-f.com/geopos"
},
"branch": "master",
"submodules": false,
- "revision": "067e52bc973931680da025b4f012f92f94bdbe53",
+ "revision": "dd4f453210c50a7f52cc436119e834ab84daf5b7",
"url": null,
- "hash": "sha256-nARH2JYrVJzchbm7JKXyGtMSCqgHI40XKb7eQS8UjQo="
+ "hash": "sha256-a8Tc+B7GyyXuMp6jCJXCoKunA6A+k2d6TApCbRUOYcY="
},
"my-git-grep-exporter": {
"type": "Git",