nix-config/hosts/nixedo/modules/forgejo.nix

43 lines
931 B
Nix
Raw Normal View History

2025-04-30 01:10:02 +01:00
{ config, lib, ... }:
2025-01-06 12:00:00 +00:00
2025-04-30 01:10:02 +01:00
with lib;
let
cfg = homelab.services.${service};
homelab = config.nixosModules.homelab;
service = "forgejo";
in
2025-01-06 12:00:00 +00:00
{
2025-04-30 01:10:02 +01:00
options.nixosModules.homelab.services.${service} = {
enable = mkEnableOption "Enable ${service}";
2025-01-06 12:00:00 +00:00
2025-04-30 01:10:02 +01:00
cloudflared.tunnelId = mkOption {
example = "00000000-0000-0000-0000-000000000000";
type = types.str;
};
2025-01-06 12:00:00 +00:00
2025-04-30 01:10:02 +01:00
url = mkOption {
default = "code.${homelab.baseDomain}";
type = types.str;
};
};
config = mkIf cfg.enable {
services = {
${service} = {
enable = true;
stateDir = "/var/www/${service}";
settings = {
server.DOMAIN = cfg.url;
service.DISABLE_REGISTRATION = true;
2025-01-06 12:00:00 +00:00
};
};
2025-04-30 01:10:02 +01:00
cloudflared.tunnels.${cfg.cloudflared.tunnelId}.ingress = {
${cfg.url} = "http://localhost:${toString config.services.${service}.settings.server.HTTP_PORT}";
};
2025-01-06 12:00:00 +00:00
};
};
}