1
0
Fork 0
nix-configuration/modules/nixos/services/forgejo/default.nix

61 lines
1.6 KiB
Nix
Raw Normal View History

{
config,
lib,
2024-12-06 18:04:47 +00:00
namespace,
...
}:
let
2024-12-06 18:04:47 +00:00
cfg = config.${namespace}.services.forgejo;
in
{
options = {
2024-12-06 18:04:47 +00:00
${namespace}.services.forgejo = {
2024-09-08 15:58:56 +00:00
enable = lib.mkEnableOption "Enables Forgejo Git hosting service.";
home = lib.mkOption {
default = "";
type = lib.types.str;
2024-05-21 00:52:57 +00:00
description = "Where to store Forgejo's files";
2024-06-04 18:18:45 +00: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";
};
};
};
config = lib.mkIf cfg.enable {
services = {
forgejo = {
enable = true;
2024-09-28 17:39:05 +00:00
settings = {
server = {
DOMAIN = lib.${namespace}.getDomainFromURI cfg.url;
2024-09-28 17:39:05 +00:00
ROOT_URL = cfg.url;
HTTP_PORT = 3000;
2024-09-28 17:39:05 +00:00
};
indexer.REPO_INDEXER_ENABLED = true; # Enable code indexing
};
useWizard = true;
} // lib.optionalAttrs (cfg.home != null) { stateDir = cfg.home; };
2024-05-27 16:32:24 +00:00
nginx.virtualHosts."${cfg.url}" = {
useACMEHost = lib.${namespace}.getDomainFromURI cfg.url;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:3000";
proxyWebsockets = true;
extraConfig = "proxy_ssl_server_name on;"; # required when the target is also TLS server with multiple hosts
2024-06-25 18:13:15 +00:00
};
};
};
systemd.services = {
2024-09-07 17:44:14 +00:00
forgejo.unitConfig.RequiresMountsFor = cfg.home;
nginx.wants = [ config.systemd.services.forgejo.name ];
};
};
}