This document covers the installation steps for hg.sr.ht, a SourceHut service for hosting Mercurial repositories.
Notice: hg.sr.ht is hosted on SourceHut and maintained independently by members of the Mercurial community. The community maintaner is Ludovic Chabant.
Familiarize yourself with the general installation documentation before getting started.
The following daemons are available in the hg.sr.ht package:
hg.sr.ht — The web service.hg.sr.ht-api — The API service.Enable and start them like so:
# service hg.sr.ht start
# service hg.sr.ht-api start
# rc-update add hg.sr.ht
# rc-update add hg.sr.ht-api
Install a cronjob to run hg.sr.ht-periodic as the hg user. The recommended
frequency is every 20 minutes:
*/20 * * * * chronic hg.sr.ht-periodic
It is recommended to run an additional, optional cronjob,
hg.sr.ht-clonebundles, daily:
0 * * * * chronic hg.sr.ht-clonebundles
hg.sr.ht requires a location on the host filesystem to store Mercurial
repositories, which is readable and writable by the "hg" user. The recommended
location is /var/lib/mercurial.
Like git.sr.ht, hg.sr.ht uses SourceHut's unified SSH dispatcher, which you need to set up as the system-wide SSH authorization hook. See git.sr.ht's Installation page for more information.
Once this is done, you need to make the hg.sr.ht shell be part of the SSH
dispatching, via the hg.sr.ht-shell script. See the [hg.sr.ht] section of
your hg.sr.ht configuration for more details.
Authorization logs are written to /var/log/sourcehut-ssh.log.
hg.sr.ht does not do HTTP(S) cloning for you, so you'll need to set it up yourself in Nginx. Here's an example Nginx configuration:
location = /authorize {
proxy_pass http://127.0.0.1:5010;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
location ~ ^/[~^][a-z0-9_]+/[a-zA-Z0-9_.-]+/\.hg.*$ {
auth_request /authorize;
root /var/lib/mercurial;
}
It is important that you set up the /authorize endpoint to enforce the
privacy of private repositories.
commit dfef7b0770d694dcb1fabc6c663459c7eb2e8a2d Author: CismonX <admin@cismon.net> Date: 2026-01-31T08:24:33+08:00 builds.sr.ht: update FreeBSD support status - freebsd/current image is now updated daily - freebsd/13.x image is now updated monthly