aboutsummaryrefslogtreecommitdiffstats
path: root/hg.sr.ht/installation.md
blob: a8ac21881688ec22a0cdb60b1f1bc5ad93c31703 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
title: hg.sr.ht installation
---

hg.sr.ht is the hg repository hosting service for the sr.ht network.

# Installation

hg.sr.ht is a standard sr.ht web service and can be installed through the
[standard procedure](/installation.md). However, there are several additional
steps required.

## Repository storage

You will need to set up a directory for repositories to be stored in - we
suggest `/var/lib/hg/`. Also configure a `hg` user and assign ownership over
`/var/lib/hg/` to this user. The hg.sr.ht package will automatically prepare
these for you. If you do not use the package, you must create the user yourself
and ensure that the hg.sr.ht web application runs as this user.

## SSH dispatch

At the moment, hg.sr.ht uses git.sr.ht's SSH dispatcher, which you need to setup
as the system-wide SSH authorization hook. See the [git.sr.ht
documentation](../git.sr.ht/installation.md#ssh-dispatch) for more information.

Once this is done, you need to make the hg.sr.ht authorization hook be part of
the SSH dispatching, via the `hgsrht-keys` and `hgsrht-shell` scripts. See the
`[dispatch]` section of you hg.sr.ht configuration for details on how this
works.

Authorization logs are written to `hg-srht-shell`.

## Cronjobs

You must also configure `hgsrht-periodic` to run periodically with your
favorite cron daemon. We recommend the following crontab:

    */20 * * * * hgsrht-periodic

If you'd like to generate
[clonebundles](https://www.mercurial-scm.org/wiki/ClonebundlesExtension) (which
require more disk space but dramatically speed up cloning large repositories),
also add a nightly task for running the script:

    0 * * * * hgsrht-clonebundles

## HTTP(s) Cloning

hg.sr.ht does not do this for you - you need to wire it up in nginx. Here's an
example config:

```nginx
location = /authorize {
		proxy_pass http://127.0.0.1:5001;
		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;
}
```