As an open source project, you are encouraged to install SourceHut on your own infrastructure or deploy it locally to hack on it and contribute improvements upstream. This document familiarizes you with the internals of SourceHut and the installation and deployment of the software on your own systems.

Note: Just want to get up and running quickly on your development machine for testing, contributing, and exploration? Consider using the community-maintained sr.ht-container-compose environment to get started quickly.

Background

SourceHut is a distributed system of "mini-services", such as git, builds, todo, and so on. You can deploy all of these services or a subset of them as your use-case requires. The only service which is required is meta.sr.ht, which provides account management and authentication for the other services.

The following components are common to most services:

  • A GraphQL API daemon (Go)
  • A web frontend (Python)

Some services only have an API (e.g. pages.sr.ht), others only have a frontend (e.g. man.sr.ht). Many services also have various other components, such as the build workers that power builds.sr.ht, the SSH pipeline common to git.sr.ht, hg.sr.ht, and builds.sr.ht, or the email ingress for lists.sr.ht. Many services have cronjobs and various ancillary executables for various purposes, or have other unique requirements which are documented on their respective pages.

Prerequisites

SourceHut requires the following software to be available and configured by the user separately from the rest of SourceHut:

  • PostgreSQL, including one database per service.
  • A Redis-compatible key/value store. We use Redict in production.
  • The mail server of your choice. We use Postfix in production. If you don't need to receive emails on your instance, you can use any SMTP provider.
  • The web server of your choice. We use nginx in production outside of some special cases (notably pages.sr.ht).
  • An S3-compatible object store (optional). We use Ceph's radosgw in production.

The installation, configuration, and maintenance of these prerequisites is out of scope for this documentation.

System requirements

At small scales, you can install all SourceHut services on a single server. The server requirements scale depending on your use-case -- SourceHut's software is generally lightweight but you will need to consider, for example, how much git storage you require and what kind of traffic you expect. A basic installation for up to several dozen users including, for example, the following services:

  • meta.sr.ht: account services
  • git.sr.ht and/or hg.sr.ht: source code hosting
  • todo.sr.ht: bug tracking
  • man.sr.ht: wikis
  • hub.sr.ht: project management

Can be supported by virtually any small VPS. The following services present more challenges to deploy:

  • lists.sr.ht: requires a comprehensive mail system, including a clean IP address and a hosting provider willing to allow outgoing SMTP, plus the relatively odious process of setting up a mail server which can handle both incoming and outgoing mail with SPF, DKIM, etc
  • builds.sr.ht: generally requires a bare-metal server to run the build workers with KVM, and in particular requires nested KVM support (which is not offered by most VPS providers) in order to allow build images to build and test themselves.
Alpine Linux

All of our services run on Alpine Linux in production. Alpine is strongly recommended for most production deployments of SourceHut, and is the only officially supported environment. You can learn about our third-party Alpine Linux package repository here.

Note: Braver sysadmins can probably get SourceHut running on just about any POSIX-compatible system, but you're on your own.

Ongoing maintenance and security

If you run a production instance of SourceHut you are strongly encouraged to subscribe to the sr.ht-admins mailing list. This is a low-volume mailing list which notifies downstream sysadmins of important information for the maintenance of their instance, such as upgrades which require manual intervention, or notice of security vulnerabilities.

Service installation and configuration

The high-level installation process is generally as follows for each service:

  1. Configure the SourceHut Alpine Linux package repository
  2. Install the appropriate package for each service (e.g. git.sr.ht)
  3. Initialize the PostgreSQL database
  4. Prepare a suitable config.ini file in /etc/sr.ht/
  5. Start/enable the OpenRC services (e.g. service git.sr.ht-api start)
  6. Configure a reverse proxy

Each service may have unique steps or requirements for the complete installation. Consult the documentation for each service here:

Service configuration (config.ini)

An example config.ini file is provided in the source code repository for each service. These configurations can be merged if you run more than one service on a single server. Each example configuration is commented throughout -- you are encouraged to read the example from start to finish and fill in the necessary fields and adapt it to your own use-case.

Database initialization and maintenance

Each service requires a PostgreSQL database and a user with ownership and all necessary permissions that apply to its database. To initialize the database, run sourcehut-migrate $service init.

Database migrations are also provided by the sourcehut-migrate package, which is based on brant; see sourcehut-migrate -h for its usage. Migrations are generally handled automatically during package upgrades if [$service]migrate-on-upgrade is set to "yes".

Reverse proxy configuration

We use nginx in production as a reverse proxy for SourceHut services. You can see how we configure it in the sr.ht-nginx repository for reference.

chat.sr.ht

chat.sr.ht is built almost entirely out of third-party software, namely soju and gamja. We apply some downstream patches to soju to support SourceHut accounts for authentication -- browse our patches here.

Contributor guidelines

We accept contributions for all of SourceHut's code on the sr.ht-dev mailing list, where we accept patches prepared with git send-email. This is also where we handle most of our development discussions and proposals.

Test your changes

While we recognize that it is pretty annoying to get SourceHut up and running to test small changes, we still expect that all contributors test their changes prior to submitting patches.

LLM policy

Please note that we do not accept code authored by or assisted by an LLM or other AI tool in SourceHut's various codebases.

About this wiki

commit 90bf271c0b6c13987072198b9044c63fbb176477
Author: Michael Forney <mforney@mforney.org>
Date:   2026-10-30T16:53:15-07:00

builds.sr.ht/compatibility: NetBSD was updated to 11.0 and 10.2
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)