diff --git a/hosts/terre-neuvas/configuration.nix b/hosts/terre-neuvas/configuration.nix index 0a6c5c7..77b7456 100644 --- a/hosts/terre-neuvas/configuration.nix +++ b/hosts/terre-neuvas/configuration.nix @@ -46,7 +46,6 @@ environment.systemPackages = with pkgs; [ neovim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. git - hugo ]; networking = { useNetworkd = true; diff --git a/modules/sites/levr.porzh.me.nix b/modules/sites/levr.porzh.me.nix index cc1d9ed..7401c30 100644 --- a/modules/sites/levr.porzh.me.nix +++ b/modules/sites/levr.porzh.me.nix @@ -1,27 +1,33 @@ -_: { - # ----------------------------------------------------------------- - # 1️⃣ Caddy (reverse‑proxy / serveur web statique) - # ----------------------------------------------------------------- +{ pkgs, lib, ...}: { + environment.systemPackages = with pkgs; [ + hugo + ]; + systemd.services.hugo-build = { + description = "Auto build du blog hugo"; + after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; + serviceConfig = { + Type = "oneshot"; + WorkingDirectory = "/srv/blog" ; + ExecStart = '' + ${pkgs.git}/bin/git pull origin master + ${pkgs.hugo}/bin/hugo --minify build -d /srv/blog/public + ''; + User = "lomig"; + }; + environment = { + PATH = lib.mkForce "${pkgs.git}/bin:${pkgs.hugo}/bin:${pkgs.openssh}/bin"; + }; + }; + systemd.timers.hugo-build = { + description = "Timer pour rebuild du blog"; + wantedBy = [ "timers.target" ]; + timerConfig.OnCalendar = "daily" ; + }; services.caddy = { enable = true; - - # Caddy démarre en tant qu’utilisateur « caddy ». - # On lui donne accès au répertoire du blog via les ACL créées plus haut. - # (Pas besoin de config supplémentaire côté OS.) - - # ----------------------------------------------------------------- - # 2️⃣ Sites gérés par Caddy (Caddyfile intégré) - # ----------------------------------------------------------------- virtualHosts = { "levr.porzh.me" = { - # Le domaine sera automatiquement provisionné avec TLS via ACME - # (Let's Encrypt) grâce à l’option `autoHTTPS = true` (défaut). - # Aucun certificat manuel n’est requis. - - # Le répertoire contenant les fichiers générés par Hugo - - # (Optionnel) Rediriger HTTP → HTTPS – Caddy le fait déjà, - # mais on le rend explicite pour la clarté. extraConfig = '' @http { protocol http @@ -37,12 +43,4 @@ _: { }; }; }; - - # ----------------------------------------------------------------- - # 3️⃣ Ouverture du firewall (ports 80 et 443) - # ----------------------------------------------------------------- - # networking.firewall.allowedTCPPorts = [ - # 80 # HTTP (pour la redirection ACME) - # 443 # HTTPS (site final) - # ]; }