2024-09-09 00:22:14 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
inputs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2024-09-13 01:50:53 +00:00
|
|
|
with lib; let
|
2024-10-06 15:16:52 +00:00
|
|
|
cfg = config.custom.containers.forgejo;
|
2024-09-13 01:50:53 +00:00
|
|
|
in {
|
2024-10-06 15:16:52 +00:00
|
|
|
options.custom.containers.forgejo.enable = mkOption {default = false;};
|
2024-09-09 00:22:14 +00:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-09-13 01:50:53 +00:00
|
|
|
age.secrets = let
|
|
|
|
secret = filename: {
|
|
|
|
file = "${inputs.self}/secrets/${filename}";
|
2024-09-09 00:22:14 +00:00
|
|
|
};
|
2024-09-13 01:50:53 +00:00
|
|
|
in {
|
|
|
|
"${config.custom.profile}/forgejo/.env" = secret "${config.custom.profile}/forgejo/.env";
|
|
|
|
"${config.custom.profile}/forgejo/db.env" = secret "${config.custom.profile}/forgejo/db.env";
|
|
|
|
};
|
2024-09-09 00:22:14 +00:00
|
|
|
|
|
|
|
#?? arion-forgejo pull
|
|
|
|
environment.shellAliases.arion-forgejo = "sudo arion --prebuilt-file ${config.virtualisation.arion.projects.forgejo.settings.out.dockerComposeYaml}";
|
|
|
|
|
2024-09-13 01:50:53 +00:00
|
|
|
networking.firewall.allowedTCPPorts = [22]; # SSH
|
2024-09-09 00:22:14 +00:00
|
|
|
|
|
|
|
virtualisation.arion.projects.forgejo = {
|
|
|
|
serviceName = "forgejo";
|
|
|
|
|
|
|
|
settings.services = {
|
|
|
|
# https://codeberg.org/forgejo/forgejo
|
|
|
|
# https://forgejo.org/docs/latest/admin/
|
|
|
|
#?? docker exec -it forgejo bash
|
|
|
|
#?? sudo -u git forgejo admin user create --username USERNAME --random-password --email EMAIL --admin
|
|
|
|
forgejo.service = {
|
|
|
|
container_name = "forgejo";
|
2024-09-13 01:50:53 +00:00
|
|
|
depends_on = ["db"];
|
|
|
|
env_file = [config.age.secrets."${config.custom.profile}/forgejo/.env".path];
|
2024-09-09 00:22:14 +00:00
|
|
|
image = "codeberg.org/forgejo/forgejo:8";
|
|
|
|
restart = "unless-stopped";
|
2024-10-06 15:16:52 +00:00
|
|
|
volumes = ["${config.custom.containers.directory}/forgejo/data:/data"];
|
2024-09-09 00:22:14 +00:00
|
|
|
|
|
|
|
ports = [
|
|
|
|
"127.0.0.1:3333:3000"
|
|
|
|
"22:2222"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
db.service = {
|
|
|
|
container_name = "forgejo-db";
|
2024-09-13 01:50:53 +00:00
|
|
|
env_file = [config.age.secrets."${config.custom.profile}/forgejo/db.env".path];
|
2024-09-09 00:22:14 +00:00
|
|
|
image = "postgres:15";
|
|
|
|
restart = "unless-stopped";
|
2024-10-06 15:16:52 +00:00
|
|
|
volumes = ["${config.custom.containers.directory}/forgejo/db:/var/lib/postgresql/data"];
|
2024-09-09 00:22:14 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|