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

81 lines
2 KiB
Nix
Raw Permalink Normal View History

2025-10-09 15:34:37 +02:00
{ pkgs, lib, ...}:
let
2025-10-09 17:40:43 +02:00
globals = import ../../config/globals.nix ;
2025-10-09 15:34:37 +02:00
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 15:34:37 +02:00
WorkingDirectory = globals.services.levr.home ;
ExecStart = ''${pkgs.hugo}/bin/hugo --minify build -d ${globals.services.levr.build}'';
User = "levr";
2025-10-08 11:03:57 +02:00
};
};
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 15:34:37 +02:00
WorkingDirectory = globals.services.levr.home;
2025-10-20 07:46:55 +02:00
ExecStart = "${pkgs.git}/bin/git pull --rebase origin master";
User = "levr";
2025-10-09 02:27:33 +02:00
};
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:40:43 +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 15:34:37 +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:40:43 +02:00
output file /var/log/caddy/access-${globals.services.levr.url}.log
2025-10-09 02:27:33 +02:00
}
2025-09-20 14:57:06 +02:00
'';
};
};
};
users = {
users = {
"${globals.services.levr.user}" = {
isSystemUser = true ;
group = globals.services.levr.user ;
home = globals.services.levr.home ;
createHome = true ;
description = "User for hugo-blog builds and deployments";
};
};
groups.${globals.services.levr.user} = {};
};
systemd.tmpfiles.rules = [
"d ${globals.services.levr.home} 0755 levr levr -"
"d ${globals.services.levr.build} 0755 levr levr -"
];
}