2024-05-20 12:27:01 -04:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
2024-06-24 11:38:28 -04:00
|
|
|
cfg = config.aux.system.services.forgejo;
|
2024-05-20 12:27:01 -04:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
2024-06-24 11:38:28 -04:00
|
|
|
aux.system.services.forgejo = {
|
2024-09-08 11:58:56 -04:00
|
|
|
enable = lib.mkEnableOption "Enables Forgejo Git hosting service.";
|
2024-05-20 12:27:01 -04:00
|
|
|
home = lib.mkOption {
|
2024-05-21 09:22:03 -04:00
|
|
|
default = "";
|
2024-05-20 12:27:01 -04:00
|
|
|
type = lib.types.str;
|
2024-05-20 20:52:57 -04:00
|
|
|
description = "Where to store Forgejo's files";
|
2024-06-04 14:18:45 -04:00
|
|
|
example = "/home/forgejo";
|
|
|
|
};
|
|
|
|
url = lib.mkOption {
|
|
|
|
default = "";
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "The complete URL where Forgejo is hosted.";
|
|
|
|
example = "https://forgejo.example.com";
|
|
|
|
};
|
2024-05-20 12:27:01 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-07-02 16:19:15 -04:00
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services = {
|
|
|
|
forgejo = {
|
|
|
|
enable = true;
|
2024-09-28 13:39:05 -04:00
|
|
|
settings = {
|
|
|
|
server = {
|
|
|
|
DOMAIN = pkgs.util.getDomainFromURL cfg.url;
|
|
|
|
ROOT_URL = cfg.url;
|
2024-10-05 15:49:27 -04:00
|
|
|
HTTP_PORT = 3000;
|
2024-09-28 13:39:05 -04:00
|
|
|
};
|
|
|
|
indexer.REPO_INDEXER_ENABLED = true; # Enable code indexing
|
2024-07-02 16:19:15 -04:00
|
|
|
};
|
|
|
|
useWizard = true;
|
|
|
|
} // lib.optionalAttrs (cfg.home != null) { stateDir = cfg.home; };
|
2024-05-27 12:32:24 -04:00
|
|
|
|
2024-07-02 16:19:15 -04:00
|
|
|
nginx.virtualHosts."${cfg.url}" = {
|
2024-09-08 23:47:53 -04:00
|
|
|
useACMEHost = pkgs.util.getDomainFromURL cfg.url;
|
2024-07-02 16:19:15 -04:00
|
|
|
forceSSL = true;
|
|
|
|
locations."/" = {
|
2024-10-05 15:49:27 -04:00
|
|
|
proxyPass = "http://127.0.0.1:3000";
|
2024-07-02 16:19:15 -04:00
|
|
|
proxyWebsockets = true;
|
|
|
|
extraConfig = "proxy_ssl_server_name on;"; # required when the target is also TLS server with multiple hosts
|
2024-06-25 14:13:15 -04:00
|
|
|
};
|
2024-07-02 16:19:15 -04:00
|
|
|
};
|
|
|
|
};
|
2024-08-29 11:59:28 -04:00
|
|
|
|
|
|
|
systemd.services = {
|
2024-09-07 13:44:14 -04:00
|
|
|
forgejo.unitConfig.RequiresMountsFor = cfg.home;
|
2024-08-29 11:59:28 -04:00
|
|
|
nginx.wants = [ config.systemd.services.forgejo.name ];
|
|
|
|
};
|
2024-07-02 16:19:15 -04:00
|
|
|
};
|
2024-05-20 12:27:01 -04:00
|
|
|
}
|