host(koumakan): mirrors

Changed files
+61
systems
koumakan
+1
systems/koumakan/services/default.nix
···
./ci
./databases
+
./mirror
./proxies
./scm
./security
+34
systems/koumakan/services/mirror/archt2.nix
···
+
{ pkgs, ... }:
+
{
+
systemd = {
+
# TODO: make this a gensokyo module
+
timers."mirror-sync-t2" = {
+
after = [ "network-online.target" ];
+
wants = [ "network-online.target" ];
+
wantedBy = [ "multi-user.target" ];
+
timerConfig = {
+
OnCalendar = "*:30";
+
RandomizedDelaySec = "600s";
+
DeferReactivation = true;
+
Persistent = true;
+
};
+
};
+
+
services."mirror-sync-t2" = {
+
path = [pkgs.rsync];
+
script = ''
+
touch /var/lib/mirrors/{arch,endeavouros}-mact2
+
+
rsync -rlptH --safe-links --delete-delay --delay-updates \
+
rsync://mirror.funami.tech/arch-mact2 /var/lib/mirrors/arch-mact2
+
+
rsync -rlptH --safe-links --delete-delay --delay-updates \
+
rsync://mirror.funami.tech/endeavouros-mact2 /var/lib/mirrors/endeavouros-mact2
+
'';
+
+
serviceConfig = {
+
User = "mirror-worker";
+
};
+
};
+
};
+
}
+26
systems/koumakan/services/mirror/default.nix
···
+
{ _utils, config, ... }:
+
{
+
imports = [
+
+
];
+
+
users.groups."mirror-worker" = {};
+
users.users."mirror-worker" = {
+
isSystemUser = true;
+
group = "mirror-worker";
+
};
+
+
services.nginx.virtualHosts."mirror.soopy.moe" = _utils.mkVhost {
+
locations."/".root = "/var/lib/mirrors";
+
};
+
+
services.nginx.virtualHosts."keine.soopy.moe".globalRedirect = "mirror.soopy.moe";
+
+
# provision a directory for mirrors
+
systemd.tmpfiles.settings."10-mirrors" = {
+
"/var/lib/mirrors".d = {
+
mode = "0755";
+
user = config.users.users.mirror-worker.name;
+
};
+
};
+
}