service/git: migrate to forgejo from gitea
Some checks failed
/ Build Nix targets (push) Has been cancelled

This commit is contained in:
Felix Buehler 2025-04-01 22:27:51 +02:00
parent b41344a212
commit 3b20c0a25b
6 changed files with 55 additions and 25 deletions

View file

@ -12,7 +12,7 @@
./finance
./freshrss
./fritzbox
./gitea
./git
./grafana
./hedgedoc
./home-automation

View file

@ -6,17 +6,41 @@
...
}:
let
cfg = config.my.services.gitea;
cfg = config.my.services.git;
inherit (config.networking) domain;
in
{
options.my.services.gitea = with lib; {
enable = mkEnableOption "Gitea";
options.my.services.git = {
enable = lib.mkEnableOption "Git server";
passwordFile = lib.mkOption {
type = lib.types.path;
example = "/var/lib/somewhere/password.txt";
description = ''
Path to a file containing the admin's password.
'';
};
};
config = lib.mkIf cfg.enable {
# configure admin user
systemd.services.forgejo.preStart =
let
adminCmd = "${lib.getExe config.services.forgejo.package} admin user";
user = "felix";
in
''
admin="${adminCmd}"
if ! $admin list | grep "${user}"; then
${adminCmd} create --admin --email "server@localhost" --username ${user} --password "$(tr -d '\n' < ${cfg.passwordFile})" || true
else
${adminCmd} change-password --username ${user} --password "$(tr -d '\n' < ${cfg.passwordFile})" || true
fi
'';
services = {
gitea = {
forgejo = {
enable = true;
settings = {
server = {
@ -35,10 +59,10 @@ in
prometheus = {
scrapeConfigs = [
{
job_name = "gitea";
job_name = "forgejo";
static_configs = [
{
targets = [ "localhost:${toString config.services.gitea.settings.server.HTTP_PORT}" ];
targets = [ "localhost:${toString config.services.forgejo.settings.server.HTTP_PORT}" ];
labels = {
instance = config.networking.hostName;
};
@ -50,39 +74,39 @@ in
grafana.provision = {
dashboards.settings.providers = [
{
name = "Gitea";
options.path = pkgs.grafana-dashboards.gitea;
name = "Forgejo";
options.path = pkgs.grafana-dashboards.forgejo;
disableDeletion = true;
}
];
};
};
# Proxy to Gitea
# Proxy to forgejo
my.services = {
webserver.virtualHosts = [
{
subdomain = "code";
port = config.services.gitea.settings.server.HTTP_PORT;
port = config.services.forgejo.settings.server.HTTP_PORT;
}
];
backup = {
paths = [
config.services.gitea.lfs.contentDir
config.services.gitea.repositoryRoot
config.services.forgejo.lfs.contentDir
config.services.forgejo.repositoryRoot
];
};
prometheus.rules = {
gitea = {
condition = ''rate(promhttp_metric_handler_requests_total{job="gitea", code="500"}[5m]) > 3'';
description = "{{$labels.instance}}: gitea instances error rate went up: {{$value}} errors in 5 minutes";
forgejo = {
condition = ''rate(promhttp_metric_handler_requests_total{job="forgejo", code="500"}[5m]) > 3'';
description = "{{$labels.instance}}: forgejo instances error rate went up: {{$value}} errors in 5 minutes";
};
};
};
webapps.apps.gitea = {
webapps.apps.git = {
dashboard = {
name = "Code";
category = "app";