refactor forgejo to its own file including nginx config

This commit is contained in:
Yisroel Baum 2026-04-09 10:52:54 +03:00
parent 1da3624a02
commit 53a94c2e61
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
2 changed files with 38 additions and 29 deletions

View file

@ -8,6 +8,7 @@
imports = imports =
[ # Include the results of the hardware scan. [ # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
./forgejo.nix
]; ];
# Bootloader. # Bootloader.
@ -52,17 +53,6 @@
Defaults timestamp_timeout=120 Defaults timestamp_timeout=120
''; '';
services.forgejo = {
enable = true;
settings = {
server = {
ROOT_URL = "https://git.${domainName}/";
PROTOCOL = "http";
DOMAIN = "git.${domainName}";
};
service.DISABLE_REGISTRATION = true;
};
};
services.logind.settings.Login = { services.logind.settings.Login = {
HandleLidSwitch = "ignore"; HandleLidSwitch = "ignore";
@ -144,24 +134,6 @@
}; };
}; };
}; };
"git.${domainName}" = {
forceSSL = true;
enableACME = true;
extraConfig = ''
client_max_body_size 512M;
'';
locations = {
"/" = {
proxyPass = "http://localhost:3000";
extraConfig = ''
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
'';
};
};
};
}; };
}; };
security.acme = { security.acme = {

37
forgejo.nix Normal file
View file

@ -0,0 +1,37 @@
{
domainName,
...
}:
{
services = {
forgejo = {
enable = true;
settings = {
server = {
ROOT_URL = "https://git.${domainName}/";
PROTOCOL = "http";
DOMAIN = "git.${domainName}";
};
service.DISABLE_REGISTRATION = true;
};
};
nginx.virtualHosts."git.${domainName}" = {
forceSSL = true;
enableACME = true;
extraConfig = ''
client_max_body_size 512M;
'';
locations = {
"/" = {
proxyPass = "http://localhost:3000";
extraConfig = ''
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
'';
};
};
};
};
}