nixos/hosts/architect/lezzo.nix
Giulio De Pasquale da8e5572b5 lezzo: Pull hourly
2023-01-01 13:31:48 +01:00

46 lines
1007 B
Nix

{ services, pkgs, lib, makeBinPath, ... }:
let
domain = "lezzo.org";
lezzo_root = "/var/lib/lezzo.org";
service_name = "lezzo-pull";
network = import ./network.nix;
mkStartScript = name: pkgs.writeShellScript "${name}.sh" ''
set -euo pipefail
cd ${lezzo_root}
git pull origin master --rebase
'';
in
{
services.nginx.virtualHosts.${domain} = {
enableACME = true;
forceSSL = true;
root = lezzo_root;
locations."/.git" = { return = "404"; };
};
systemd = {
services.${service_name} = {
path = [ pkgs.git ];
enable = true;
serviceConfig = {
Type = "oneshot";
ExecStart = mkStartScript "${service_name}";
};
};
timers.${service_name} = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "hourly";
Unit = "${service_name}.service";
};
};
};
networking.extraHosts = ''
${network.architect-lan} ${domain}
${network.architect-wg} ${domain}
'';
}