45 lines
946 B
Nix
45 lines
946 B
Nix
{ lib, pkgs, config, inputs, ... }:
|
|
let
|
|
repoDir = "/var/www/site";
|
|
in
|
|
{
|
|
|
|
services.nginx =
|
|
{
|
|
enable = true;
|
|
virtualHosts =
|
|
{
|
|
"farewellbird.de" = {
|
|
locations."/" = {
|
|
root = repoDir;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
systemd.timers."clone-repo" = {
|
|
wantedBy = [ "timers.target" ];
|
|
timerConfig = {
|
|
OnBootSec = "10s";
|
|
OnUnitActiveSec = "5m";
|
|
Unit = "clone-repo.service";
|
|
};
|
|
};
|
|
systemd.services."clone-repo" = {
|
|
script = ''
|
|
set -eu
|
|
if test -d ${repoDir}; then
|
|
cd ${repoDir}
|
|
${pkgs.git}/bin/git pull
|
|
else
|
|
mkdir mkdir -p $(dirname ${repoDir})
|
|
${pkgs.git}/bin/git clone -b pages https://codeberg.org/YourLocalFops/farewellbird.git ${repoDir}
|
|
fi
|
|
'';
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
User = "root";
|
|
};
|
|
};
|
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
|
}
|