sr.ht-docs/hacking.md

3.4 KiB

title toc
Hacking on SourceHut false

This document provides information for those interested in hacking on or contributing to SourceHut.

Installation

Here are some tips to expedite the installation procedure:

  • A PostgreSQL database and Redis server are always required.
  • Some services require (or may optionally make use of) an S3-compatible storage backend. Minio is recommended for this purpose.
  • Generally, you can skip the webhooks daemons unless you need them.
  • Always prefer package installations for obtaining dependencies.
  • You can usually get away without configuring the outgoing mail settings, but you may still have to generate a PGP key to get things started up.
  • You can skip setting up a reverse proxy and use our development servers via python3 run.py instead.
  • Some services depend on other services. Some such integrations are optional, but all services depend on meta.sr.ht.

Dev dependencies

In addition to the runtime dependencies of our packages, building packages from source requires additional build-time dependencies:

  • sassc for CSS pre-processing
  • minify for minifying CSS
  • go for compiling the Go APIs
  • make for making

Generic instructions

Do this once, when starting with meta.sr.ht:

  • Check out meta.sr.ht and core.sr.ht. Make sure to clone with --recurse-submodules.
  • Copy meta.sr.ht's config.example.ini to config.ini and configure everything following the instructions in the comments.

When filling in the config.ini file, remember the following:

  • Some of the comments will ask you to run programs such as srht-keygen — these can be found in the core.sr.ht repository.
  • If you do not have SSL enabled for Postgres, be sure to add ?sslmode=disable to the end of your Postgres URL.

Then, for each SERVICE (e.g. meta.sr.ht):

  • export SRHT_PATH=/path/to/core.sr.ht/srht
  • export PYTHONPATH=/path/to/core.sr.ht:/path/to/$SERVICE
  • make all

To avoid conflicts with the email package, you should now unset PYTHONPATH.

Note that core.sr.ht is not a service, but merely a repository of code shared between services.

For each service except meta.sr.ht:

  • Copy the service's section(s) from its config.example.ini into meta.sr.ht's config.ini, modifying it according to the comments.
  • ln -s /path/to/meta.sr.ht/config.ini config.ini

For each SERVICE:

  • createdb $SERVICE (e.g. createdb meta.sr.ht)
  • psql -d $SERVICE -f schema.sql (e.g. psql -d meta.sr.ht -f schema.sql)

To run a service:

  • ./api/api (must be run before the following command)
  • python3 run.py

For the APIs to be able to talk to each other, you need to correctly register each service as a client. You will find more instructions on the meta.example.org/oauth page, as well as in the OAuth Reference. After you have created the OAuth clients, find each respective database entry in the oauthclient table, and set the preauthorized column to TRUE for each one.

Sending Patches

We use git send-email and discuss patches (and other development topics) on the sr.ht-dev list. Please send your patches and development questions there.