Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

hope

hope is a Hetzner EX44 that runs the CI runners. It takes over the GitHub runner and the NixOS GitLab runners of stormwing. All services and containers of hope are defined in nixos/hosts/hope.nix and its submodules.

Network

ItemValue
IPv465.108.193.164/26
IPv62a01:4f9:1a:95ad::2
Tailnet IP100.100.1.30
vSwitch IP10.0.0.30 (VLAN 4000)
SSH port666

Host configuration

{
  config,
  garuda-lib,
  lib,
  ...
}:
let
  mon = garuda-lib.monitoring;
  isoDir = "/data/iso/image-builder";
in
{
  imports = [
    ../modules
    ./../modules/special/hetzner-ex44.nix
  ];

  systemd.tmpfiles.rules = [
    "d ${isoDir} 0755 root root" # ISOs of the image-builder CI
    "e ${isoDir}/*/staging - - - 2d" # Staging dirs left by cancelled pipelines
  ];

  garuda =
    garuda-lib.mkMonitoring {
      host = "hope";
      lokiAddress = mon.loki.tailnetAddress;
      hostInfo = true;
      units = [
        "borgmatic.service"
        "borgmatic.timer"
        "sshd.service"
        "tailscaled.service"
      ];
      exporters = [
        "smartctlExporter"
        "borgmaticExporter"
      ];
    }
    // {
      newgen.dataDir = "/data";
      backup.borgmatic = {
        enable = true;
        name = "hope";
        user = "u342919";
        host = "u342919.your-storagebox.de";
        port = 23;
        label = "hetzner";
        sshKeySecret = "backup/ssh_hope";
        knownHosts = [
          {
            name = "storagebox-ed25519";
            publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIICf9svRenC/PLKIL9nk6K/pxQgoiFC41wTNvoIncOxs"; # pragma: allowlist secret
          }
        ];
        sourceDirectories = [
          "/data/persistent/etc"
          "/data/persistent/var/lib/nixos"
          "/data/persistent/var/lib/borgmatic"
          "/data/persistent/var/lib/vnstat"
          "/data/persistent/var/lib/tailscale"
          "/data/containers/github-runner/ssh"
          "/data/containers/gitlab-runner/gitlab-runner"
        ];
      };
    };

  zramSwap.enable = true;

  networking = {
    defaultGateway = "65.108.193.129";
    defaultGateway6 = {
      address = "fe80::1";
      interface = "eth0";
    };
    hostName = "hope";
    interfaces."eth0" = {
      ipv4.addresses = [
        {
          address = "65.108.193.164";
          prefixLength = 26;
        }
      ];
      ipv6.addresses = [
        {
          address = "2a01:4f9:1a:95ad::2";
          prefixLength = 64;
        }
      ];
    };
  };

  services.garuda-nspawn = {
    dockerCache = "/data/dockercache/";
    logDir = "/data/container-logs/";

    containers = garuda-lib.mkContainers {
      dir = ./hope;
      ips = mon.remoteHosts.hope.containers;
      containers = {
        github-runner = {
          mounts = [
            {
              name = "token";
              hostPath = config.sops.secrets."compose/github-runner".path;
              mountPoint = "/var/.github-runner.env";
              readOnly = true;
            }
            {
              name = "ssh-keys";
              hostPath = "/data/containers/github-runner/ssh";
              mountPoint = "/etc/ssh";
            }
            {
              name = "github-cache";
              hostPath = "/data/cache/github-runner";
              mountPoint = "/var/cache/github-runner";
            }
          ];
          forwardPorts = [
            {
              containerPort = 22;
              hostPort = 230;
            }
          ];
          nspawn = {
            ephemeral = lib.mkForce true;
          };
          defaults = false;
          needsDocker = true;
        };

        gitlab-runner = {
          mounts = [
            {
              name = "nix-cache";
              hostPath = "/data/containers/gitlab-runner/nix";
              mountPoint = "/nix";
            }
            {
              name = "gitlab-runner";
              hostPath = "/data/containers/gitlab-runner/gitlab-runner";
              mountPoint = "/var/lib/private/gitlab-runner";
            }
            {
              name = "iso-image-builder";
              hostPath = isoDir;
              mountPoint = "/srv/iso/image-builder";
            }
          ];
          forwardPorts = [
            {
              containerPort = 22;
              hostPort = 260;
            }
          ];
          needsDocker = true;
          needsKvm = true;

          # The Lima and VM disk step of image-builder mounts loop partitions
          needsLoopPartitions = true;

          # Docker userns-remap (unprivileged `nix` runner) needs an unmasked /proc
          writableApiVfs = true;
        };
      };
    };
  };

  systemd.services = garuda-lib.mkTunnels (garuda-lib.mkRemoteHostTunnels "hope");

  sops.secrets."compose/github-runner" = { };
}

Containers/services