2024-11-17 00:08:02 +01:00
|
|
|
{ config, values, fp, pkgs, lib, ... }:
|
2023-06-04 01:59:35 +02:00
|
|
|
let
|
|
|
|
cfg = config.services.gitea;
|
2023-09-07 18:34:58 +02:00
|
|
|
domain = "git.pvv.ntnu.no";
|
2023-06-04 01:59:35 +02:00
|
|
|
sshPort = 2222;
|
|
|
|
in {
|
2023-09-16 22:26:44 +02:00
|
|
|
imports = [
|
2024-11-23 22:26:15 +01:00
|
|
|
./gpg.nix
|
2024-08-14 21:27:43 +02:00
|
|
|
./import-users
|
|
|
|
./web-secret-provider
|
2023-09-16 22:26:44 +02:00
|
|
|
];
|
|
|
|
|
2023-06-04 01:59:35 +02:00
|
|
|
sops.secrets = {
|
|
|
|
"gitea/database" = {
|
|
|
|
owner = "gitea";
|
|
|
|
group = "gitea";
|
|
|
|
};
|
2024-05-12 01:46:18 +02:00
|
|
|
"gitea/email-password" = {
|
|
|
|
owner = "gitea";
|
|
|
|
group = "gitea";
|
|
|
|
};
|
2023-06-04 01:59:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
services.gitea = {
|
|
|
|
enable = true;
|
|
|
|
appName = "PVV Git";
|
|
|
|
|
|
|
|
database = {
|
|
|
|
type = "postgres";
|
|
|
|
host = "postgres.pvv.ntnu.no";
|
2024-06-29 20:45:54 +02:00
|
|
|
port = config.services.postgresql.settings.port;
|
2023-06-04 01:59:35 +02:00
|
|
|
passwordFile = config.sops.secrets."gitea/database".path;
|
|
|
|
createDatabase = false;
|
|
|
|
};
|
|
|
|
|
2024-05-12 01:46:18 +02:00
|
|
|
mailerPasswordFile = config.sops.secrets."gitea/email-password".path;
|
|
|
|
|
2024-06-29 22:59:28 +02:00
|
|
|
# https://docs.gitea.com/administration/config-cheat-sheet
|
2023-06-04 01:59:35 +02:00
|
|
|
settings = {
|
|
|
|
server = {
|
|
|
|
DOMAIN = domain;
|
|
|
|
ROOT_URL = "https://${domain}/";
|
|
|
|
PROTOCOL = "http+unix";
|
|
|
|
SSH_PORT = sshPort;
|
2024-04-11 21:47:47 +02:00
|
|
|
START_SSH_SERVER = true;
|
2024-07-04 20:30:55 +02:00
|
|
|
START_LFS_SERVER = true;
|
2024-07-19 21:19:06 +02:00
|
|
|
LANDING_PAGE = "explore";
|
2023-06-04 01:59:35 +02:00
|
|
|
};
|
2024-05-12 01:46:18 +02:00
|
|
|
mailer = {
|
|
|
|
ENABLED = true;
|
|
|
|
FROM = "gitea@pvv.ntnu.no";
|
|
|
|
PROTOCOL = "smtp";
|
|
|
|
SMTP_ADDR = "smtp.pvv.ntnu.no";
|
|
|
|
SMTP_PORT = 587;
|
|
|
|
USER = "gitea@pvv.ntnu.no";
|
2024-07-04 20:36:44 +02:00
|
|
|
SUBJECT_PREFIX = "[pvv-git]";
|
2024-05-12 01:46:18 +02:00
|
|
|
};
|
2024-09-14 19:16:28 +02:00
|
|
|
metrics = {
|
|
|
|
ENABLED = true;
|
|
|
|
ENABLED_ISSUE_BY_LABEL = true;
|
|
|
|
ENABLED_ISSUE_BY_REPOSITORY = true;
|
|
|
|
};
|
2023-09-16 21:51:13 +02:00
|
|
|
indexer.REPO_INDEXER_ENABLED = true;
|
2024-07-04 20:41:46 +02:00
|
|
|
service = {
|
|
|
|
DISABLE_REGISTRATION = true;
|
|
|
|
ENABLE_NOTIFY_MAIL = true;
|
2024-08-27 09:26:00 +02:00
|
|
|
AUTO_WATCH_NEW_REPOS = false;
|
2024-07-04 20:41:46 +02:00
|
|
|
};
|
2024-07-10 00:18:01 +02:00
|
|
|
admin.DEFAULT_EMAIL_NOTIFICATIONS = "onmention";
|
2023-06-04 01:59:35 +02:00
|
|
|
session.COOKIE_SECURE = true;
|
|
|
|
database.LOG_SQL = false;
|
2024-06-29 22:59:28 +02:00
|
|
|
repository = {
|
|
|
|
PREFERRED_LICENSES = lib.concatStringsSep "," [
|
|
|
|
"AGPL-3.0-only"
|
|
|
|
"AGPL-3.0-or-later"
|
|
|
|
"Apache-2.0"
|
|
|
|
"BSD-3-Clause"
|
|
|
|
"CC-BY-4.0"
|
|
|
|
"CC-BY-NC-4.0"
|
|
|
|
"CC-BY-NC-ND-4.0"
|
|
|
|
"CC-BY-NC-SA-4.0"
|
|
|
|
"CC-BY-ND-4.0"
|
|
|
|
"CC-BY-SA-4.0"
|
|
|
|
"CC0-1.0"
|
|
|
|
"GPL-2.0-only"
|
|
|
|
"GPL-3.0-only"
|
|
|
|
"GPL-3.0-or-later"
|
|
|
|
"LGPL-3.0-linking-exception"
|
|
|
|
"LGPL-3.0-only"
|
|
|
|
"LGPL-3.0-or-later"
|
|
|
|
"MIT"
|
|
|
|
"MPL-2.0"
|
|
|
|
"Unlicense"
|
|
|
|
];
|
|
|
|
DEFAULT_REPO_UNITS = lib.concatStringsSep "," [
|
|
|
|
"repo.code"
|
|
|
|
"repo.issues"
|
|
|
|
"repo.pulls"
|
|
|
|
"repo.releases"
|
|
|
|
];
|
|
|
|
};
|
2023-06-04 01:59:35 +02:00
|
|
|
picture = {
|
|
|
|
DISABLE_GRAVATAR = true;
|
|
|
|
ENABLE_FEDERATED_AVATAR = false;
|
|
|
|
};
|
2023-09-16 21:51:13 +02:00
|
|
|
actions.ENABLED = true;
|
2024-10-12 22:42:59 +02:00
|
|
|
ui = {
|
|
|
|
REACTIONS = lib.concatStringsSep "," [
|
|
|
|
"+1"
|
|
|
|
"-1"
|
|
|
|
"laugh"
|
|
|
|
"confused"
|
|
|
|
"heart"
|
|
|
|
"hooray"
|
|
|
|
"rocket"
|
|
|
|
"eyes"
|
|
|
|
"100"
|
|
|
|
"anger"
|
|
|
|
"astonished"
|
|
|
|
"no_good"
|
|
|
|
"ok_hand"
|
|
|
|
"pensive"
|
|
|
|
"pizza"
|
|
|
|
"point_up"
|
|
|
|
"sob"
|
|
|
|
"skull"
|
|
|
|
"upside_down_face"
|
|
|
|
"shrug"
|
|
|
|
];
|
|
|
|
};
|
2023-09-07 18:34:58 +02:00
|
|
|
"ui.meta".DESCRIPTION = "Bokstavelig talt programvareverkstedet";
|
2023-06-04 01:59:35 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-09-07 18:34:58 +02:00
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
|
2023-06-04 01:59:35 +02:00
|
|
|
services.nginx.virtualHosts."${domain}" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
2024-04-10 22:01:19 +02:00
|
|
|
kTLS = true;
|
2024-09-14 19:16:28 +02:00
|
|
|
locations = {
|
|
|
|
"/" = {
|
|
|
|
proxyPass = "http://unix:${cfg.settings.server.HTTP_ADDR}";
|
|
|
|
extraConfig = ''
|
|
|
|
client_max_body_size 512M;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
"/metrics" = {
|
|
|
|
proxyPass = "http://unix:${cfg.settings.server.HTTP_ADDR}";
|
|
|
|
extraConfig = ''
|
|
|
|
allow ${values.hosts.ildkule.ipv4}/32;
|
|
|
|
deny all;
|
|
|
|
'';
|
|
|
|
};
|
2023-06-04 01:59:35 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ sshPort ];
|
|
|
|
|
2024-04-11 21:47:47 +02:00
|
|
|
# Extra customization
|
|
|
|
|
|
|
|
services.gitea-themes.monokai = pkgs.gitea-theme-monokai;
|
|
|
|
|
|
|
|
systemd.services.install-gitea-customization = {
|
|
|
|
description = "Install extra customization in gitea's CUSTOM_DIR";
|
|
|
|
wantedBy = [ "gitea.service" ];
|
|
|
|
requiredBy = [ "gitea.service" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
};
|
|
|
|
|
|
|
|
script = let
|
2024-11-17 00:08:02 +01:00
|
|
|
logo-svg = fp /assets/logo_blue_regular.svg;
|
|
|
|
logo-png = fp /assets/logo_blue_regular.png;
|
2024-08-14 16:57:08 +02:00
|
|
|
extraLinks = pkgs.writeText "gitea-extra-links.tmpl" ''
|
|
|
|
<a class="item" href="https://www.pvv.ntnu.no/">PVV</a>
|
|
|
|
<a class="item" href="https://wiki.pvv.ntnu.no/">Wiki</a>
|
|
|
|
<a class="item" href="https://git.pvv.ntnu.no/Drift/-/projects/4">Tokyo Drift Issues</a>
|
|
|
|
'';
|
2024-04-11 21:47:47 +02:00
|
|
|
in ''
|
2024-07-04 20:29:50 +02:00
|
|
|
install -Dm444 ${logo-svg} ${cfg.customDir}/public/assets/img/logo.svg
|
|
|
|
install -Dm444 ${logo-png} ${cfg.customDir}/public/assets/img/logo.png
|
|
|
|
install -Dm444 ${./loading.apng} ${cfg.customDir}/public/assets/img/loading.png
|
2024-08-14 16:57:08 +02:00
|
|
|
install -Dm444 ${extraLinks} ${cfg.customDir}/templates/custom/extra_links.tmpl
|
2024-04-11 21:47:47 +02:00
|
|
|
'';
|
|
|
|
};
|
2023-06-04 01:59:35 +02:00
|
|
|
}
|