diff --git a/hosts/lab/wynne.nix b/hosts/lab/wynne.nix index 5a276a8..4d0c57d 100644 --- a/hosts/lab/wynne.nix +++ b/hosts/lab/wynne.nix @@ -2,6 +2,14 @@ let port = 4322; dataDir = "/srv/wynne"; + + deployScript = pkgs.writeShellScript "wynne-deploy" '' + set -e + cd ${dataDir}/repo + ${pkgs.git}/bin/git pull + ${pkgs.pnpm}/bin/pnpm install --frozen-lockfile + ASTRO_DB_REMOTE_URL=file:${dataDir}/data/guestbook.db ${pkgs.pnpm}/bin/pnpm build + ''; in { services.caddy.virtualHosts."wynne.rs" = { @@ -17,9 +25,19 @@ in ''; }; + systemd.services.wynne-deploy = { + description = "Build wynne.rs from source"; + serviceConfig = { + Type = "oneshot"; + User = "lew"; + ExecStart = deployScript; + }; + }; + systemd.services.wynne = { description = "wynne.rs"; - after = [ "network.target" ]; + after = [ "network.target" "wynne-deploy.service" ]; + requires = [ "wynne-deploy.service" ]; wantedBy = [ "multi-user.target" ]; environment = { HOST = "127.0.0.1";