Add forgejo

This commit is contained in:
L0m1g 2025-09-15 18:20:53 +02:00
parent 4f411004e6
commit 6cf61cb4f5
7 changed files with 136 additions and 12 deletions

View file

@ -1,4 +1,4 @@
_: {
{ pkgs, ...}: {
services.caddy = {
enable = true;
virtualHosts."blog.lomig.me" = {
@ -10,4 +10,25 @@ _: {
};
networking.firewall.allowedTCPPorts = [ 80 443 ];
systemd.tmpfiles.rules = [
"d /var/www/lomig 0755 lomig users -"
];
systemd.services.hugo-blog-build = {
description = "Build Hugo Blog";
after = [ "network.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = /home/lomig/scripts/blog-sync-and-build.sh;
User = "lomig";
};
};
systemd.timers.hugo-blog-build = {
description = "Daily Hugo Blog Build";
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "daily 06:00";
Persistent = true;
};
};
}

View file

@ -0,0 +1,72 @@
# NixOS module Forgejo avec SQLite, SSH et reverse proxy Caddy
{ config, pkgs, lib, ... }: {
# --- Utilisateur dédié ---
users.users.git = {
isSystemUser = true;
home = "/var/lib/forgejo";
shell = pkgs.bash;
group = "git";
};
users.groups.git = {};
# --- Forgejo ---
services.forgejo = {
enable = true;
user = "git";
group = "git";
database = {
type = "sqlite3";
path = "/var/lib/forgejo/data/gitea.db";
};
settings = {
server = {
DOMAIN = "git.lomig.me";
ROOT_URL = "https://git.lomig.me/";
SSH_DOMAIN = "git.lomig.me";
HTTP_PORT = 3000;
SSH_PORT = 22;
START_SSH_SERVER = false;
};
service = {
DISABLE_REGISTRATION = true;
REGISTER_EMAIL_CONFIRM = false;
};
repository = {
DEFAULT_BRANCH = "main";
};
};
};
# --- Ouvrir les ports nécessaires ---
networking.firewall.allowedTCPPorts = [ 80 443 2222 ];
# --- Rediriger port SSH interne de Forgejo ---
services.openssh.enable = true;
networking.firewall.interfaces."eth0".allowedTCPPorts = [ 22 ]; # pour admin
# --- Caddy pour git.lomig.me ---
services.caddy = {
enable = true;
virtualHosts."git.lomig.me" = {
extraConfig = ''
reverse_proxy localhost:3000
'';
};
};
# --- Pour que Forgejo génère les bonnes URLs Git ---
# networking.hostName = "git"; # non strictement obligatoire
# --- Optionnel : config DNS ---
# git.lomig.me -> ton IP publique (ou IP locale si LAN)
# --- Pour te cloner un dépôt : ---
# git clone git@git.lomig.me:lomig/nom-du-repo.git
# --- Astuce : génère une paire de clés pour laccès SSH Git ---
# ssh-keygen -t ed25519 -f ~/.ssh/id_git_forgejo
# puis ajoute la clé publique dans ton compte Forgejo
}

View file

@ -0,0 +1,24 @@
{
virtualisation.oci-containers.containers.pihole = {
image = "pihole/pihole:latest";
autoStart = true;
ports = [
"53:53/udp"
"53:53/tcp"
"80:80/tcp"
];
environment = {
TZ = "Europe/Paris";
WEBPASSWORD = "changeme"; # Change à ta convenance
PIHOLE_DNS_ = "1.1.1.1;1.0.0.1";
};
volumes = [
"/srv/pihole/etc-pihole:/etc/pihole"
"/srv/pihole/etc-dnsmasq.d:/etc/dnsmasq.d"
];
extraOptions = [ "--cap-add=NET_ADMIN" ];
};
}