nixos-server/services/gitea.nix

85 lines
2.1 KiB
Nix
Raw Normal View History

2024-05-25 15:12:56 +02:00
{ pkgs, lib, ... }:
{
2024-05-24 11:13:36 +02:00
name = "gitea";
config = {
services.gitea = {
enable = true;
2024-06-20 14:56:34 +02:00
lfs.enable = true;
appName = "githug"; # Give the site a name
2024-05-25 15:12:56 +02:00
user = "git";
2024-05-24 11:13:36 +02:00
database = {
2024-06-20 14:56:34 +02:00
type = "mysql";
host = "mariadb.containers";
port = 3306;
2024-05-24 22:30:04 +02:00
name = "gitea";
user = "gitea";
createDatabase = false;
2024-06-20 14:56:34 +02:00
passwordFile = ../secrets/gitea_mariadb_pass;
2024-05-24 11:13:36 +02:00
};
2024-06-20 14:56:34 +02:00
settings = {
server = {
# DOMAIN = "githug.xyz";
# ROOT_URL = "https://githug.xyz/";
# COOKIE_SECURE = true;
HTTP_PORT = 3001;
OFFLINE_MODE = true;
};
repository.ENABLE_PUSH_CREATE_USER = true;
mailer.ENABLED = false;
service = {
REGISTER_EMAIL_CONFIRM = false;
ENABLE_NOTIFY_EMAIL = false;
DISABLE_REGISTRATION = true;
};
2024-05-30 21:57:23 +02:00
};
2024-05-24 11:13:36 +02:00
};
2024-05-25 15:12:56 +02:00
services.openssh = {
enable = true;
settings = {
PermitRootLogin = "no";
PasswordAuthentication = false;
};
};
users.users.git = {
home = "/var/lib/gitea";
group = "git";
shell = pkgs.bashInteractive;
isSystemUser = true;
};
users.groups.git = {};
2024-06-20 14:56:34 +02:00
2024-05-24 11:13:36 +02:00
};
ports = {
2024-05-25 15:12:56 +02:00
tcp = [ 3001 22 ];
2024-05-24 11:13:36 +02:00
udp = [];
http = 3001;
2024-05-25 15:12:56 +02:00
forward = [ { container = 22; host = 22; proto = "tcp"; } ];
2024-05-24 11:13:36 +02:00
};
2024-05-30 21:57:23 +02:00
hosts = [ "githug.xyz" ];
2024-05-25 01:01:07 +02:00
volumes = [{
name = "gitea-statedir";
mountPoint = "/var/lib/gitea";
2024-05-25 15:12:56 +02:00
}];
2024-06-20 14:56:34 +02:00
hostConfig = {
system.activationScripts.gitea-custom-files =
let customs = pkgs.stdenv.mkDerivation {
name = "gitea-custom";
src = ./..;
phases = [ "installPhase" ];
installPhase = ''
cp -r $src/resources/gitea-custom $out
'';
};
in ''
mkdir -p ${lib.hostVolumeDir}/gitea-statedir/custom
rm -rf ${lib.hostVolumeDir}/gitea-statedir/custom/public
rm -rf ${lib.hostVolumeDir}/gitea-statedir/custom/templates
cp -rf ${customs}/public ${lib.hostVolumeDir}/gitea-statedir/custom
cp -rf ${customs}/templates ${lib.hostVolumeDir}/gitea-statedir/custom
'';
};
2024-05-24 11:13:36 +02:00
}