system/machines/magenta/services/gitea.nix

140 lines
4.2 KiB
Nix
Raw Normal View History

2022-10-18 00:42:23 +03:00
{ config, pkgs, lib, ... }:
2022-10-18 00:42:23 +03:00
let
hostname = "nix-git.pleshevski.ru";
gitea = pkgs.gitea.overrideAttrs (oldAttrs: {
postInstall = with pkgs; ''
mkdir $data
cp -R ./go/src/${oldAttrs.goPackagePath}/{public,templates,options} $data
mkdir -p $out
cp -R ./go/src/${oldAttrs.goPackagePath}/options/locale $out/locale
wrapProgram $out/bin/gitea \
--prefix PATH : ${lib.makeBinPath [ bash git gzip openssh gnupg ]}
'';
});
in
2022-10-18 00:42:23 +03:00
{
services.postgresql.package = pkgs.postgresql_14;
programs.git = {
enable = true;
config = {
user = {
email = "gitea@noreply.pleshevski.ru";
name = "Gitea";
2022-10-18 00:42:23 +03:00
signingKey = "745324BD4A15B11F5725B8E6A29AAC22198EF078";
2022-10-18 00:42:23 +03:00
};
2022-10-18 00:42:23 +03:00
gpg.program = "${pkgs.gnupg}/bin/gpg";
2022-10-18 00:42:23 +03:00
commit.gpgSign = true;
tag.gpgSign = true;
};
};
programs.gnupg.agent.enable = true;
services.gitea = {
enable = true;
2022-10-18 00:42:23 +03:00
package = gitea;
2022-10-18 00:42:23 +03:00
httpPort = 9901;
domain = hostname;
rootUrl = "https://${hostname}";
appName = "Pleshevskiy Git Repositories";
mailerPasswordFile = config.age.secrets.gitea-mailserver-passfile.path;
database = {
type = "postgres";
host = "/run/postgresql";
port = config.services.postgresql.port;
};
lfs.enable = true;
settings = {
log = {
LEVEL = "Debug";
ENABLE_SSH_LOG = true;
};
database = {
CHARSET = "utf8";
LOG_SQL = false;
};
server.DISABLE_ROUTER_LOG = true;
service = {
ALLOW_ONLY_EXTERNAL_REGISTRATION = false;
DEFAULT_KEEP_EMAIL_PRIVATE = false;
DEFAULT_ALLOW_CREATE_ORGANIZATION = true;
DEFAULT_ENABLE_TIMETRACKING = true;
DEFAULT_ENABLE_DEPENDENCIES = false;
DISABLE_REGISTRATION = true;
ENABLE_NOTIFY_MAIL = false;
ENABLE_CAPTCHA = false;
ENABLE_TIMETRACKING = false;
REQUIRE_SIGNIN_VIEW = false;
REGISTER_EMAIL_CONFIRM = false;
NO_REPLY_ADDRESS = "noreply.pleshevski.ru";
};
repository = {
DISABLE_MIGRATIONS = false;
DISABLE_HTTP_GIT = false;
DISABLE_STARS = true;
DEFAULT_BRANCH = "main";
DEFAULT_CLOSE_ISSUES_VIA_COMMITS_IN_ANY_BRANCH = true;
};
"repository.signing" = {
2022-10-18 00:42:23 +03:00
SIGNING_EMAIL = "gitea@noreply.pleshevski.ru";
SIGNING_NAME = "Gitea";
SIGNING_KEY = "745324BD4A15B11F5725B8E6A29AAC22198EF078";
2022-10-18 00:42:23 +03:00
DEFAULT_TRUST_MODEL = "collaboratorcommiter";
MERGES = "pubkey,basesigned,commitssigned";
};
"repository.local" = {
LOCAL_COPY_PATH = "${config.services.gitea.stateDir}/tmp/local-repo";
};
"repository.upload" = {
TEMP_PATH = "${config.services.gitea.stateDir}/uploads";
ALLOWED_TYPES = "image/*";
};
"repository.pull-request" = {
WORK_IN_PROGRESS_PREFIXES = "Draft:,[Draft]:,WIP:,[WIP]:";
};
indexer = {
ISSUE_INDEXER_PATH = "${config.services.gitea.stateDir}/indexers/issues.bleve";
};
sessions = {
PROVIDER = "file";
PROVIDER_CONFIG = "${config.services.gitea.stateDir}/sessions";
};
picture = {
AVATAR_UPLOAD_PATH = "${config.services.gitea.stateDir}/avatars";
REPOSITORY_AVATAR_UPLOAD_PATH = "${config.services.gitea.stateDir}/repo-avatars";
DISABLE_GRAVATAR = false;
ENABLE_FEDERATED_AVATAR = true;
};
attachment = {
PATH = "${config.services.gitea.stateDir}/attachments";
};
mailer = {
ENABLED = true;
MAILER_TYPE = "smtp";
FROM = "\"${config.services.gitea.appName}\" <no-reply@pleshevski.ru>";
USER = "dmitriy@pleshevski.ru";
HOST = "mail.pleshevski.ru:465";
};
openid = {
ENABLE_OPENID_SIGNIN = true;
ENABLE_OPENID_SIGNUP = false;
};
};
};
services.nginx.virtualHosts.${hostname} = {
enableACME = true;
forceSSL = true;
locations."/".proxyPass = "http://localhost:${toString config.services.gitea.httpPort}/";
};
age.secrets.gitea-mailserver-passfile = {
file = ../../../secrets/mailserver-users-jan-passfile.age;
owner = config.services.gitea.user;
group = "gitea";
};
}