From 41c8f8dd0501ea9509a3275d6ca0d25c12cc920c Mon Sep 17 00:00:00 2001 From: DuN0z Date: Thu, 9 Oct 2025 02:27:33 +0200 Subject: [PATCH] Fix: hugo autobuild --- modules/sites/levr.porzh.me.nix | 54 +++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/modules/sites/levr.porzh.me.nix b/modules/sites/levr.porzh.me.nix index 7401c30..41fa232 100644 --- a/modules/sites/levr.porzh.me.nix +++ b/modules/sites/levr.porzh.me.nix @@ -4,43 +4,57 @@ ]; 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 - ''; + ExecStart = ''${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" ; + timerConfig = { + OnCalendar = "01:10" ; + Persistent = true ; + }; + }; + systemd.services.blog-sync = { + description = "Synchronisation du dépôt Hugo"; + serviceConfig = { + Type = "oneshot"; + WorkingDirectory = "/srv/blog"; + ExecStart = "${pkgs.git}/bin/git pull origin master"; + User = "lomig"; + }; + environment = { + PATH = lib.mkForce "${pkgs.openssh}/bin"; + }; + }; + systemd.timers.blog-sync = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "01:00"; + Persistent = true; + }; }; services.caddy = { enable = true; virtualHosts = { "levr.porzh.me" = { extraConfig = '' - @http { - protocol http - } - redir @http https://{host}{uri} permanent - root * /srv/blog/public - file_server + @http { + protocol http + } + redir @http https://{host}{uri} permanent + root * /srv/blog/public + file_server - log { - output file /var/log/caddy/access-levr.porzh.me.log - } + log { + output file /var/log/caddy/access-levr.porzh.me.log + } ''; }; }; }; -} + }