Sourcehut
Sourcehut is an open-source,
self-hostable software development platform. The server setup can be automated using
services.sourcehut.
Basic usage
Sourcehut is a Python and Go based set of applications.
services.sourcehut
by default will use
services.nginx,
services.redis,
services.cron,
and
services.postgresql.
A very basic configuration may look like this:
{ pkgs, ... }:
let
fqdn =
let
join = hostName: domain: hostName + optionalString (domain != null) ".${domain}";
in join config.networking.hostName config.networking.domain;
in {
networking = {
hostName = "srht";
domain = "tld";
firewall.allowedTCPPorts = [ 22 80 443 ];
};
services.sourcehut = {
enable = true;
originBase = fqdn;
services = [ "meta" "man" "git" ];
settings = {
"sr.ht" = {
environment = "production";
global-domain = fqdn;
origin = "https://${fqdn}";
# Produce keys with srht-keygen from sourcehut.coresrht.
network-key = "SECRET";
service-key = "SECRET";
};
webhooks.private-key= "SECRET";
};
};
security.acme.certs."${fqdn}".extraDomainNames = [
"meta.${fqdn}"
"man.${fqdn}"
"git.${fqdn}"
];
services.nginx = {
enable = true;
# only recommendedProxySettings are strictly required, but the rest make sense as well.
recommendedTlsSettings = true;
recommendedOptimisation = true;
recommendedGzipSettings = true;
recommendedProxySettings = true;
# Settings to setup what certificates are used for which endpoint.
virtualHosts = {
"${fqdn}".enableACME = true;
"meta.${fqdn}".useACMEHost = fqdn:
"man.${fqdn}".useACMEHost = fqdn:
"git.${fqdn}".useACMEHost = fqdn:
};
};
}
The hostName option is used internally to configure the nginx
reverse-proxy. The settings attribute set is
used by the configuration generator and the result is placed in /etc/sr.ht/config.ini.
Configuration
All configuration parameters are also stored in
/etc/sr.ht/config.ini which is generated by
the module and linked from the store to ensure that all values from config.ini
can be modified by the module.
Using an alternative webserver as reverse-proxy (e.g. httpd)
By default, nginx is used as reverse-proxy for sourcehut.
However, it's possible to use e.g. httpd by explicitly disabling
nginx using and fixing the
settings.