-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
247 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ _: { | |
./coredns | ||
./firefly-iii | ||
./firefoxsync | ||
./forgejo | ||
./lldap | ||
./maddy | ||
./mail-archive | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
APP_NAME = Forgejo: Beyond coding. We forge. | ||
RUN_MODE = prod | ||
RUN_USER = git | ||
|
||
[repository] | ||
ROOT = /var/lib/gitea/git/repositories | ||
DEFAULT_PRIVATE = private | ||
DISABLE_STARS = true | ||
DEFAULT_BRANCH = master | ||
|
||
[repository.upload] | ||
TEMP_PATH = /tmp/gitea/uploads | ||
|
||
[repository.local] | ||
LOCAL_COPY_PATH = /tmp/gitea/local-repo | ||
|
||
[badges] | ||
ENABLED = true | ||
|
||
[ui] | ||
DEFAULT_THEME = forgejo-dark | ||
|
||
[server] | ||
APP_DATA_PATH = /var/lib/gitea | ||
PROTOCOL = http | ||
HTTP_PORT = 3000 | ||
DISABLE_SSH = false | ||
START_SSH_SERVER = true | ||
BUILTIN_SSH_SERVER_USER = git | ||
SSH_PORT = 2222 | ||
OFFLINE_MODE = true | ||
ENABLE_PPROF = false | ||
LFS_START_SERVER = true | ||
|
||
[database] | ||
SSL_MODE = disable | ||
DB_TYPE = postgres | ||
HOST = host.docker.internal | ||
NAME = forgejo | ||
SCHEMA = public | ||
USER = forgejo | ||
|
||
[indexer] | ||
REPO_INDEXER_ENABLED = false | ||
ISSUE_INDEXER_TYPE = db | ||
|
||
[queue] | ||
TYPE = redis | ||
|
||
[admin] | ||
DISABLE_REGULAR_ORG_CREATION = false | ||
|
||
[security] | ||
INSTALL_LOCK = true | ||
REVERSE_PROXY_LIMIT = 1 | ||
REVERSE_PROXY_AUTHENTICATION_USER = Remote-User | ||
REVERSE_PROXY_AUTHENTICATION_EMAIL = Remote-Email | ||
REVERSE_PROXY_TRUSTED_PROXIES = 172.16.0.0/12 | ||
|
||
[service] | ||
DISABLE_REGISTRATION = true | ||
REQUIRE_SIGNIN_VIEW = true | ||
ENABLE_NOTIFY_MAIL = true | ||
ENABLE_REVERSE_PROXY_AUTHENTICATION = true | ||
ENABLE_REVERSE_PROXY_AUTO_REGISTRATION = false | ||
ENABLE_REVERSE_PROXY_EMAIL = false | ||
DEFAULT_ALLOW_CREATE_ORGANIZATION = true | ||
|
||
[mailer] | ||
ENABLED = true | ||
PROTOCOL = smtp | ||
SMTP_ADDR = maddy | ||
SMTP_PORT = 25 | ||
FORCE_TRUST_SERVER_CERT = true | ||
SUBJECT_PREFIX = [GIT] | ||
|
||
[cache] | ||
ADAPTER = redis | ||
|
||
[session] | ||
PROVIDER = redis | ||
|
||
[picture] | ||
DISABLE_GRAVATAR = true | ||
ENABLE_FEDERATED_AVATAR = false | ||
AVATAR_UPLOAD_PATH = /var/lib/gitea/data/avatars | ||
REPOSITORY_AVATAR_UPLOAD_PATH = /var/lib/gitea/data/repo-avatars | ||
|
||
[attachment] | ||
ENABLED = true | ||
MAX_SIZE = 64 | ||
PATH = /var/lib/gitea/data/attachments | ||
|
||
[log] | ||
MODE = console | ||
|
||
[log.console] | ||
FLAGS = journaldflags | ||
STDERR = true | ||
COLORIZE = false | ||
|
||
[federation] | ||
ENABLED = false | ||
|
||
[lfs] | ||
PATH = /var/lib/gitea/git/lfs | ||
|
||
[actions] | ||
ENABLED = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
{ | ||
config, | ||
lib, | ||
pkgs, | ||
svc, | ||
... | ||
}: | ||
let | ||
cfg = config.mySystemApps.forgejo; | ||
secretEnvs = [ | ||
"FORGEJO__cache__HOST" | ||
"FORGEJO__database__PASSWD" | ||
"FORGEJO__oauth2__JWT_SECRET" | ||
"FORGEJO__queue__CONN_STR" | ||
"FORGEJO__security__INTERNAL_TOKEN" | ||
"FORGEJO__security__SECRET_KEY" | ||
"FORGEJO__server__LFS_JWT_SECRET" | ||
"FORGEJO__session__PROVIDER_CONFIG" | ||
]; | ||
in | ||
{ | ||
options.mySystemApps.forgejo = { | ||
enable = lib.mkEnableOption "forgejo container"; | ||
backup = lib.mkEnableOption "postgresql and data backup" // { | ||
default = true; | ||
}; | ||
dataDir = lib.mkOption { | ||
type = lib.types.str; | ||
description = "Path to directory containing data."; | ||
default = "/var/lib/forgejo"; | ||
}; | ||
sopsSecretPrefix = lib.mkOption { | ||
type = lib.types.str; | ||
description = "Prefix for sops secret, under which all ENVs will be appended."; | ||
default = "system/apps/forgejo/env"; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
warnings = [ (lib.mkIf (!cfg.backup) "WARNING: Backups for forgejo are disabled!") ]; | ||
|
||
sops.secrets = svc.mkContainerSecretsSops { | ||
inherit (cfg) sopsSecretPrefix; | ||
inherit secretEnvs; | ||
|
||
containerName = "forgejo"; | ||
}; | ||
|
||
mySystemApps.postgresql.userDatabases = [ | ||
{ | ||
username = "forgejo"; | ||
passwordFile = config.sops.secrets."${cfg.sopsSecretPrefix}/FORGEJO__database__PASSWD".path; | ||
databases = [ "forgejo" ]; | ||
} | ||
]; | ||
|
||
virtualisation.oci-containers.containers.forgejo = svc.mkContainer { | ||
cfg = { | ||
image = "codeberg.org/forgejo/forgejo:9.0.1-rootless@sha256:871b9ee033bbce261cb8306240f05cc902c118b40ddba2a72d8111f1ba0fe30e"; | ||
environment = | ||
{ | ||
FORGEJO__server__DOMAIN = "git.${config.mySystem.rootDomain}"; | ||
FORGEJO__server__SSH_DOMAIN = "git.${config.mySystem.rootDomain}"; | ||
FORGEJO__server__ROOT_URL = "https://git.${config.mySystem.rootDomain}"; | ||
FORGEJO__mailer__FROM = config.mySystem.notificationSender; | ||
FORGEJO__time__DEFAULT_UI_LOCATION = config.mySystem.time.timeZone; | ||
} | ||
// svc.mkContainerSecretsEnv { | ||
inherit secretEnvs; | ||
suffix = "__FILE"; | ||
}; | ||
ports = [ "2222:2222" ]; | ||
volumes = | ||
svc.mkContainerSecretsVolumes { | ||
inherit (cfg) sopsSecretPrefix; | ||
inherit secretEnvs; | ||
} | ||
++ [ "${cfg.dataDir}:/var/lib/gitea" ]; | ||
extraOptions = [ | ||
"--mount" | ||
"type=tmpfs,destination=/tmp,tmpfs-mode=1777" | ||
]; | ||
}; | ||
opts = { | ||
# to expose port to host, public network must be used | ||
allowPublic = true; | ||
}; | ||
}; | ||
|
||
services = { | ||
nginx.virtualHosts.forgejo = svc.mkNginxVHost { | ||
host = "git"; | ||
proxyPass = "http://forgejo.docker:3000"; | ||
}; | ||
postgresqlBackup = lib.mkIf cfg.backup { databases = [ "forgejo" ]; }; | ||
restic.backups = lib.mkIf cfg.backup ( | ||
svc.mkRestic { | ||
name = "forgejo"; | ||
paths = [ cfg.dataDir ]; | ||
} | ||
); | ||
}; | ||
|
||
systemd.services.docker-forgejo = { | ||
path = [ pkgs.diffutils ]; | ||
preStart = lib.mkAfter '' | ||
mkdir -p "${cfg.dataDir}/custom/conf" | ||
cp ${./app.ini} "${cfg.dataDir}/custom/conf/app.ini" | ||
chown 1000:1000 "${cfg.dataDir}" "${cfg.dataDir}/custom" "${cfg.dataDir}/custom/conf" "${cfg.dataDir}/custom/conf/app.ini" | ||
chmod 640 "${cfg.dataDir}/custom/conf/app.ini" | ||
# ugly hack to fix forgejo permissions, as sops-nix doesn't allow setting direct UID/GID yet | ||
chown -R 1000:1000 "$(dirname ${ | ||
config.sops.secrets."${cfg.sopsSecretPrefix}/${builtins.elemAt secretEnvs 0}".path | ||
})" | ||
''; | ||
}; | ||
|
||
environment.persistence."${config.mySystem.impermanence.persistPath}" = | ||
lib.mkIf config.mySystem.impermanence.enable | ||
{ directories = [ cfg.dataDir ]; }; | ||
}; | ||
} |