nixos-config/modules/sites/levr.porzh.me.nix

64 lines
1.6 KiB
Nix
Raw Normal View History

2025-10-09 17:46:15 +02:00
{ pkgs, lib, ...}:
let
import = ../../config/globals.nix ;
in {
2025-10-08 11:03:57 +02:00
environment.systemPackages = with pkgs; [
hugo
];
systemd.services.hugo-build = {
description = "Auto build du blog hugo";
serviceConfig = {
Type = "oneshot";
2025-10-09 17:46:15 +02:00
WorkingDirectory = globals.services.levr.home ;
ExecStart = ''${pkgs.hugo}/bin/hugo --minify build -d ${globals.services.levr.build}'';
2025-10-08 11:03:57 +02:00
User = "lomig";
};
};
systemd.timers.hugo-build = {
description = "Timer pour rebuild du blog";
wantedBy = [ "timers.target" ];
2025-10-09 02:27:33 +02:00
timerConfig = {
OnCalendar = "01:10" ;
Persistent = true ;
};
};
systemd.services.blog-sync = {
description = "Synchronisation du dépôt Hugo";
serviceConfig = {
Type = "oneshot";
2025-10-09 17:46:15 +02:00
WorkingDirectory = globals.services.levr.home;
2025-10-09 02:27:33 +02:00
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;
};
2025-10-08 11:03:57 +02:00
};
2025-09-20 14:57:06 +02:00
services.caddy = {
enable = true;
virtualHosts = {
2025-10-09 17:46:15 +02:00
globals.services.levr.url = {
2025-09-20 14:57:06 +02:00
extraConfig = ''
2025-10-09 02:27:33 +02:00
@http {
protocol http
}
redir @http https://{host}{uri} permanent
2025-10-09 17:46:15 +02:00
root * ${globals.services.levr.build}
2025-10-09 02:27:33 +02:00
file_server
2025-09-24 23:33:06 +02:00
2025-10-09 02:27:33 +02:00
log {
2025-10-09 17:46:15 +02:00
output file /var/log/caddy/access-${global.services.levr.url}.log
2025-10-09 02:27:33 +02:00
}
2025-09-20 14:57:06 +02:00
'';
};
};
};
2025-10-09 02:27:33 +02:00
}