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 maintainer is Ludovic Chabant.

Installation

Familiarize yourself with the general installation documentation before getting started.

Daemons

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

Cronjobs

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

Configuration

Repository storage

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.

SSH dispatch

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.

HTTP(S) Cloning

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.

About this wiki

commit 8d6d72442c116c48f9bdeaf11429f906c1e0f993
Author: CismonX <admin@cismon.net>
Date:   2026-05-12T11:45:59+08:00

Fix typos

Noticed a typo while reading the docs, so I ran crate-ci/typos
on the entire repo, and fixed them once and for all :)

Notes:
- "publically" is not necessarily a typo, but it is considered
  non-standard in modern English. Use "publicly" instead.
- Similar case with "moreso".
Clone this wiki ("master" branch)
https://git.sr.ht/~sircmpwn/sr.ht-docs (read-only)
git@git.sr.ht:~sircmpwn/sr.ht-docs (read/write)