From f1db2b7f6a632625dd1d5a168bdb9bfaf1e99885 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Tue, 2 Apr 2024 11:55:07 -0500 Subject: [PATCH] Move vbox to Hosea --- hosts/hosea/default.nix | 59 ++++++++++++++++++++++++++++++++++++++++- hosts/myself/git.nix | 54 +------------------------------------ 2 files changed, 59 insertions(+), 54 deletions(-) diff --git a/hosts/hosea/default.nix b/hosts/hosea/default.nix index a0e6d92..faa014c 100644 --- a/hosts/hosea/default.nix +++ b/hosts/hosea/default.nix @@ -2,7 +2,7 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ config, pkgs, ... }: +{ config, pkgs, lib, inputs, overlays, ... }: let wanInterface = "enp2s0"; lanInterface = "enp1s0"; @@ -47,4 +47,61 @@ in variant = ""; }; }; + + ##################################################################################### + #################### Virtualbox Runner ############################################## + ##################################################################################### + systemd.services."container@gitlab-runner-vbox" = { + # Moved here from myself/Isaiah, so technically unnecessary now + conflicts = [ + "container@gitlab-runner-qemu.service" + ]; + serviceConfig = { + DevicePolicy = lib.mkForce "auto"; + ExecStopPost = [ "${pkgs.kmod}/bin/rmmod vboxnetadp vboxnetflt vboxdrv" ]; + ExecStartPre = [ + "${pkgs.kmod}/bin/modprobe vboxdrv" + "${pkgs.kmod}/bin/modprobe vboxnetadp" + "${pkgs.kmod}/bin/modprobe vboxnetflt" + ]; + }; + }; + + containers.gitlab-runner-vbox = { + bindMounts."/etc/ssh/ssh_host_ed25519_key".hostPath = "/etc/ssh/ssh_host_ed25519_key"; # For agenix secrets + privateNetwork = true; + bindMounts = { + "/dev/vboxdrv" = { + hostPath = "/dev/vboxdrv"; + isReadOnly = false; + }; + "/dev/vboxdrvu" = { + hostPath = "/dev/vboxdrvu"; + isReadOnly = false; + }; + "/dev/vboxnetctl" = { + hostPath = "/dev/vboxnetctl"; + isReadOnly = false; + }; + }; + hostAddress = "192.168.202.1"; + localAddress = "192.168.202.2"; + config = ((import ../myself/container-runner.nix) { + inherit inputs overlays; + name = "vbox"; + extra = { + systemd.services.gitlab-runner.serviceConfig = { + User = "root"; + DynamicUser = lib.mkForce false; + }; + virtualisation.virtualbox.host = { + enable = true; + enableExtensionPack = true; + enableHardening = false; + headless = true; + }; + networking.firewall.allowedTCPPorts = [ 18083 ]; # Should be interface for vboxweb + }; + }); + }; } diff --git a/hosts/myself/git.nix b/hosts/myself/git.nix index cb224c8..ee6b52d 100644 --- a/hosts/myself/git.nix +++ b/hosts/myself/git.nix @@ -39,6 +39,7 @@ in { systemd.services = { "container@gitlab-runner-qemu" = { + # Now moved to a separate machine conflicts = [ "container@gitlab-runner-vbox.service" ]; @@ -51,20 +52,6 @@ in { ]; }; }; - "container@gitlab-runner-vbox" = { - conflicts = [ - "container@gitlab-runner-qemu.service" - ]; - serviceConfig = { - DevicePolicy = lib.mkForce "auto"; - ExecStopPost = [ "${pkgs.kmod}/bin/rmmod vboxnetadp vboxnetflt vboxdrv" ]; - ExecStartPre = [ - "${pkgs.kmod}/bin/modprobe vboxdrv" - "${pkgs.kmod}/bin/modprobe vboxnetadp" - "${pkgs.kmod}/bin/modprobe vboxnetflt" - ]; - }; - }; gitlab-runner.serviceConfig.EnvironmentFile = config.age.secrets.docker-auth.path; }; @@ -101,45 +88,6 @@ in { }); }; - ##################################################################################### - #################### Virtualbox Runner ############################################## - ##################################################################################### - containers.gitlab-runner-vbox = container { - bindMounts = { - "/dev/vboxdrv" = { - hostPath = "/dev/vboxdrv"; - isReadOnly = false; - }; - "/dev/vboxdrvu" = { - hostPath = "/dev/vboxdrvu"; - isReadOnly = false; - }; - "/dev/vboxnetctl" = { - hostPath = "/dev/vboxnetctl"; - isReadOnly = false; - }; - }; - hostAddress = "192.168.202.1"; - localAddress = "192.168.202.2"; - config = ((import ./container-runner.nix) { - inherit inputs overlays; - name = "vbox"; - extra = { - systemd.services.gitlab-runner.serviceConfig = { - User = "root"; - DynamicUser = lib.mkForce false; - }; - virtualisation.virtualbox.host = { - enable = true; - enableExtensionPack = true; - enableHardening = false; - headless = true; - }; - networking.firewall.allowedTCPPorts = [ 18083 ]; # Should be interface for vboxweb - }; - }); - }; - ##################################################################################### #################### Container Podman Runner ######################################## #####################################################################################