feat(nixos): add control center host with hypervisor gitops service

This commit is contained in:
Tibo De Peuter 2026-07-27 22:01:40 +02:00
parent 89cec4e0f3
commit dc9b7a30d9
Signed by: tdpeuter
SSH key fingerprint: SHA256:u/h/LVoqKF1Iz02uOyxe6hcjmoZASCGV2HM0TG9ZMoU
10 changed files with 259 additions and 42 deletions

View file

@ -2,5 +2,6 @@
imports = [
./actions
./openssh
./hypervisor-gitops
];
}

View file

@ -0,0 +1,64 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.homelab.services.hypervisor-gitops;
hypervisorSyncScript = pkgs.writeShellApplication {
name = "hypervisor-sync";
runtimeInputs = with pkgs; [ git opentofu coreutils ];
text = builtins.readFile ../../../../scripts/hypervisor-sync.sh;
};
in {
options.homelab.services.hypervisor-gitops = {
enable = mkEnableOption "Hypervisor GitOps Service";
repoUrl = mkOption {
type = types.str;
description = "The URL of the git repository to pull";
};
# TODO Replace with webhooks
pollInterval = mkOption {
type = types.str;
default = "hourly";
description = "Systemd calendar event for polling interval";
};
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
git
opentofu
];
systemd.services.hypervisor-gitops = {
description = "Hypervisor GitOps Polling Service";
# We need network access to reach Forgejo and Proxmox API
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
serviceConfig = {
Type = "oneshot";
User = "root"; # Needs root to read SOPS secrets potentially
# We will create a state directory for the repo
StateDirectory = "hypervisor-gitops";
WorkingDirectory = "/var/lib/hypervisor-gitops";
ExecStart = "${hypervisorSyncScript}/bin/hypervisor-sync ${cfg.repoUrl} opentofu/nodes/mikoshi";
};
};
systemd.timers.hypervisor-gitops = {
description = "Timer for Hypervisor GitOps Service";
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = cfg.pollInterval;
Persistent = true;
};
};
};
}