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

gitlab-runner (hope)

This container runs the NixOS GitLab runners hope-nix-caching and hope-nix-privileged. Both build through the nix-daemon of the container, so all jobs share one Nix store and do not download the same paths again.

Runners

RunnerTagMode
hope-nix-cachingnixUnprivileged. Docker remaps the job root to an unprivileged UID (userns-remap = "dockremap"), so jobs talk to the nix-daemon as untrusted users. No /dev/kvm in the job.
hope-nix-privilegednix-privilegedPrivileged, no user namespace remapping (--docker-userns host), with /dev/kvm. Jobs run as root.

A job only reaches these runners if its CI configuration sets the tag nix or nix-privileged.

Nix expression

{
  config,
  garuda-lib,
  sources,
  ...
}:
{
  imports = sources.defaultModules ++ [ ../../modules ];

  garuda = garuda-lib.mkMonitoring {
    host = "hope";
    units = [
      "docker.service"
      "gitlab-runner.service"
    ];
  };

  networking.firewall.interfaces."eth0".allowedTCPPorts = [ 9252 ];

  services.garuda-gitlab-runner = {
    enable = true;
    runners = {
      hope-nix-caching = {
        authenticationTokenConfigFile = config.sops.secrets."gitlab-runner/runners/hope-nix-caching".path;
        nix-caching.enable = true;
      };

      # Privileged and root (no userns remap), with /dev/kvm.
      # Set to "protected" in GitLab, so only main branch jobs reach it.
      hope-nix-privileged = {
        authenticationTokenConfigFile =
          config.sops.secrets."gitlab-runner/runners/hope-nix-privileged".path;
        nix-privileged.enable = true;
        kvm.enable = true;
        # The ISO jobs of image-builder write to /data/iso/image-builder on the host
        dockerExtraVolumes = [ "/srv/iso/image-builder:/publish/iso" ];
      };
    };
    volumeCleanup.enable = true;
  };

  sops.secrets = garuda-lib.mkSecrets [
    "gitlab-runner/runners/hope-nix-caching"
    "gitlab-runner/runners/hope-nix-privileged"
  ];

  system.stateVersion = "26.11";
}