reciproka-ops/profiles/gitea.nix

104 lines
2.7 KiB
Nix
Raw Permalink Normal View History

2021-10-07 02:13:48 +00:00
# NixOps configuration for the hosts running Gitea
{
2022-08-15 07:32:25 +00:00
config,
pkgs,
lib,
...
}: {
2021-10-07 02:13:48 +00:00
services.gitea = {
2022-08-15 07:32:25 +00:00
enable = true; # Enable Gitea
appName = "JFDI Collective: Gitea Service"; # Give the site a name
2021-10-07 02:13:48 +00:00
database = {
2022-08-15 07:32:25 +00:00
type = "postgres"; # Database type
passwordFile = "/run/keys/gitea-dbpass"; # Where to find the password
2021-10-07 02:13:48 +00:00
};
disableRegistration = true;
2022-08-15 07:32:25 +00:00
domain = "source.jfdic.org"; # Domain name
rootUrl = "https://source.jfdic.org/"; # Root web URL
httpPort = 3002; # Provided unique port
2021-10-07 02:13:48 +00:00
settings = let
2022-08-15 07:32:25 +00:00
docutils = pkgs.python37.withPackages (ps:
with ps; [
docutils # Provides rendering of ReStructured Text files
pygments # Provides syntax highlighting
]);
2021-10-07 02:13:48 +00:00
in {
mailer = {
ENABLED = true;
FROM = "source@jfdic.org";
};
repository = {
DEFAULT_BRANCH = "consensus";
};
service = {
REGISTER_EMAIL_CONFIRM = true;
};
"markup.restructuredtext" = {
ENABLED = true;
FILE_EXTENSIONS = ".rst";
RENDER_COMMAND = "${docutils}/bin/rst2html.py";
IS_INPUT_FILE = false;
};
ui = {
2022-08-15 07:32:25 +00:00
DEFAULT_THEME = "gitea"; # Set the default theme
2021-10-07 02:13:48 +00:00
};
};
};
systemd = {
services = {
gitea = {
# Ensure gitea starts after nixops keys are loaded
after = ["gitea-dbpass-key.service"];
wants = ["gitea-dbpass-key.service"];
};
};
};
2021-10-07 02:13:48 +00:00
services.postgresql = {
2022-08-15 07:32:25 +00:00
enable = true; # Ensure postgresql is enabled
2021-10-07 02:13:48 +00:00
authentication = ''
local gitea all ident map=gitea-users
'';
2022-08-15 07:32:25 +00:00
identMap =
# Map the gitea user to postgresql
2021-10-07 02:13:48 +00:00
''
gitea-users gitea gitea
'';
2022-08-15 07:32:25 +00:00
ensureDatabases = ["gitea"]; # Ensure the database persists
2021-10-07 02:13:48 +00:00
ensureUsers = [
{
2022-08-15 07:32:25 +00:00
name = "gitea"; # Ensure the database user persists
ensurePermissions = {
# Ensure the database permissions persist
2021-10-07 02:13:48 +00:00
"DATABASE gitea" = "ALL PRIVILEGES";
"ALL TABLES IN SCHEMA public" = "ALL PRIVILEGES";
};
}
];
};
services.nginx = {
2022-08-15 07:32:25 +00:00
enable = true; # Enable Nginx
2021-10-07 02:13:48 +00:00
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
2022-08-15 07:32:25 +00:00
virtualHosts."source.jfdic.org" = {
# Gitea hostname
enableACME = true; # Use ACME certs
forceSSL = true; # Force SSL
locations."/".proxyPass = "http://localhost:3002/"; # Proxy Gitea
2021-10-07 02:13:48 +00:00
};
};
security.acme = {
acceptTerms = true;
certs = {
"source.jfdic.org".email = "source@jfdic.org";
};
};
2022-08-15 07:32:25 +00:00
users.groups.keys.members = ["gitea"]; # Required due to NixOps issue #1204
2021-10-07 02:13:48 +00:00
}