-- Leo's gemini proxy
-- Connecting to log.pfad.fr:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini; charset=utf-8
> TL;DR you can now run "git clone https://log.pfad.fr" to subscribe to the source of this log.
After playing with flake.nix, I noticed that I didn't want to hardcode my forge URL in the flake.nix file, just like I prefer to use a domain I control for go modules (where it is usually referred to as "vanity URL"):
So I dug to understand if and how I could use my domain for the flake inputs (while I am to lazy to self-host a code forge):
- vanitydoc.url = "git+https://codeberg.org/pfad.fr/vanitydoc.git"; + vanitydoc.url = "git+https://code.pfad.fr/vanitydoc";
Under the hood, nix is performing a git clone, so the problem moves to telling git how to look for the repository somewhere else. I remembered having seen some "warning: redirecting to ..." when performing a git clone, so I thought that I could put a simple HTTP redirection from "https://code.pfad.fr/vanitydoc.git" to the actual forge URL "https://codeberg.org/pfad.fr/vanitydoc.git". However, git failed with:
remote: 404 page not found
To get a more verbose output, set the GIT_CURL_VERBOSE environment variable to 1. It shows that git actually fetches an "augmented URL": https://code.pfad.fr/vanitydoc.git/info/refs?service=git-upload-pack. Redirecting the `.../info/refs` path instead of the root path led to the next error:
fatal: unable to update url base from redirection: asked for: ...
Maintaining the query parameters "?service=git-upload-pack" fixes the issue (and I can drop the ".git" suffix since the redirection does not conflict with the documentation anymore)!
git clone https://code.pfad.fr/vanitydoc Cloning into 'vanitydoc'... warning: redirecting to https://codeberg.org/pfad.fr/vanitydoc.git/ remote: Enumerating objects: ...
So if you want to redirect a git repository, make sure to redirect the info/refs path and keep the query string:
From: https://<clone-URL>/info/refs?service=git-upload-pack To: https://<forge-URL>/info/refs?service=git-upload-pack
The flake.nix now relies on a domain I control, so moving forges should not be a problem in the future.
After a night of sleep, I thought that I could also expose the source of this log under https://log.pfad.fr. During my previous adventures, I stumbled upon the git documentation about the "Dumb HTTP protocol".
Since I only want to expose the main branch, I added the following steps to the build pipeline of this log:
make a "bare clone" of the "main" branch of the current git repository
update the server info (recommended by the git documentation)
copy the info and objects folders as well as the HEAD and packed-refs files to the root folder exposed by my static web server (I ignore the empty branches, hooks and refs folders, as well as some placeholder files)
git clone --bare . -b main --single-branch dist/bare cd dist/bare git update-server-info rsync --archive info objects HEAD packed-refs ../http/
So you can now clone this log to subscribe to the source of it (articles are in the "content" folder):
git clone https://log.pfad.fr
Further reading on subscribing via git (accessible via the gemini protocol):
📅 2023-10-24
-- Response ended
-- Page fetched on Tue May 14 20:54:31 2024