From 72c60bd5e0150621ebadecb11e59bbdbd01bb8de Mon Sep 17 00:00:00 2001 From: DuN0z Date: Wed, 8 Oct 2025 11:03:57 +0200 Subject: [PATCH 1/3] ADD: autobuild hugo blog --- modules/sites/levr.porzh.me.nix | 49 +++++++++++++++------------------ 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/modules/sites/levr.porzh.me.nix b/modules/sites/levr.porzh.me.nix index cc1d9ed..787fbe6 100644 --- a/modules/sites/levr.porzh.me.nix +++ b/modules/sites/levr.porzh.me.nix @@ -1,27 +1,30 @@ _: { - # ----------------------------------------------------------------- - # 1️⃣ Caddy (reverse‑proxy / serveur web statique) - # ----------------------------------------------------------------- + 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"; + }; + }; + 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 +40,4 @@ _: { }; }; }; - - # ----------------------------------------------------------------- - # 3️⃣ Ouverture du firewall (ports 80 et 443) - # ----------------------------------------------------------------- - # networking.firewall.allowedTCPPorts = [ - # 80 # HTTP (pour la redirection ACME) - # 443 # HTTPS (site final) - # ]; } From 72154f92b74291812dec9ff4411c57296d931ec1 Mon Sep 17 00:00:00 2001 From: DuN0z Date: Wed, 8 Oct 2025 11:05:05 +0200 Subject: [PATCH 2/3] ADD: autobuild hugo blog --- modules/sites/levr.porzh.me.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sites/levr.porzh.me.nix b/modules/sites/levr.porzh.me.nix index 787fbe6..20280b6 100644 --- a/modules/sites/levr.porzh.me.nix +++ b/modules/sites/levr.porzh.me.nix @@ -1,4 +1,4 @@ -_: { +{ pkgs, ...}: { environment.systemPackages = with pkgs; [ hugo ]; From da8f43f652744b8af436e0fe0f81bd3b90647189 Mon Sep 17 00:00:00 2001 From: DuN0z Date: Wed, 8 Oct 2025 11:40:24 +0200 Subject: [PATCH 3/3] Fix: hugo build --- hosts/terre-neuvas/configuration.nix | 1 - modules/sites/levr.porzh.me.nix | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) 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 20280b6..7401c30 100644 --- a/modules/sites/levr.porzh.me.nix +++ b/modules/sites/levr.porzh.me.nix @@ -1,4 +1,4 @@ -{ pkgs, ...}: { +{ pkgs, lib, ...}: { environment.systemPackages = with pkgs; [ hugo ]; @@ -15,6 +15,9 @@ ''; 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";