nixos_config/hosts/tesla-nixos/configuration.nix

157 lines
4 KiB
Nix
Raw Normal View History

2025-09-29 18:03:24 +02:00
{ config, pkgs, lib, ... }:
2025-08-12 21:00:01 +02:00
{
2025-09-29 15:56:43 +02:00
security.sudo.wheelNeedsPassword = false;
2025-08-12 21:00:01 +02:00
imports =
[ ./hardware-configuration.nix ];
networking.hostName = "tesla-nixos";
boot.initrd.enable = true;
boot.loader = {
systemd-boot = {
enable = true;
}; # end loader.systemd-boot
}; # end boot
2025-09-24 18:23:45 +02:00
virtualisation.oci-containers.containers = {
isponsorblocktv = {
image = "ghcr.io/dmunozv04/isponsorblocktv:latest";
autoStart = true;
volumes = [
2025-09-24 18:33:20 +02:00
"/home/alisceon/isponsorblocktv:/app/data"
2025-09-24 18:31:24 +02:00
];
2025-09-24 18:23:45 +02:00
}; # end isponsorblocktv
};
2025-09-29 11:23:45 +02:00
boot.kernel.sysctl = {
"kernel.unprivileged_userns_clone" = 1;
};
systemd.tmpfiles.rules = [
2025-09-29 16:55:37 +02:00
"d /var/lib/gitlab-runner 0755 root root -"
"d /var/lib/gitlab-runner/builds 0755 root root -"
"d /var/lib/gitlab-runner/cache 0755 root root -"
2025-09-29 11:23:45 +02:00
];
2025-09-29 17:51:11 +02:00
networking.nat = {
enable = true;
internalInterfaces = ["ve-+"];
externalInterface = "ens18";
};
2025-09-30 19:43:18 +02:00
environment.systemPackages = with pkgs; [
fuse-overlayfs
];
2025-09-29 17:51:11 +02:00
2025-09-29 16:06:47 +02:00
containers.gitlab-runner = {
2025-09-29 11:23:45 +02:00
autoStart = true;
ephemeral = false;
2025-09-29 17:51:11 +02:00
privateNetwork = true;
2025-09-29 20:18:51 +02:00
privateUsers = "identity";
2025-09-30 11:15:18 +02:00
hostAddress = "10.250.0.1";
localAddress = "10.250.0.2";
2025-09-29 11:23:45 +02:00
2025-09-30 11:15:18 +02:00
extraFlags = [
2025-09-30 11:18:29 +02:00
"--system-call-filter=@keyring"
2025-09-30 18:27:32 +02:00
"--system-call-filter=bpf"
2025-09-30 11:15:18 +02:00
];
2025-09-29 11:23:45 +02:00
bindMounts = {
"/var/lib/gitlab-runner" = {
hostPath = "/var/lib/gitlab-runner";
isReadOnly = false;
};
2025-09-30 19:43:18 +02:00
"/proc" = {
hostPath = "/run/proc";
};
"/sys" = {
hostPath = "/run/sys";
};
"/dev/fuse" = {
hostPath = "/dev/fuse";
};
2025-09-29 11:23:45 +02:00
};
2025-09-30 19:46:08 +02:00
allowedDevices = [
2025-09-30 19:45:35 +02:00
{
path = "/dev/fuse";
access = "rwm";
}
];
2025-09-29 11:23:45 +02:00
2025-09-29 17:32:31 +02:00
# Guest (inside the nspawn container)
2025-09-29 18:03:24 +02:00
config = { pkgs, lib, ... }: {
2025-09-29 11:23:45 +02:00
networking.hostName = "ci-nspawn";
2025-09-29 19:09:03 +02:00
networking.useHostResolvConf = true;
2025-09-29 11:23:45 +02:00
time.timeZone = "UTC";
2025-09-29 17:32:31 +02:00
# Docker daemon inside the container
virtualisation.docker = {
2025-09-29 11:23:45 +02:00
enable = true;
2025-09-29 20:11:41 +02:00
autoPrune = {
enable = true;
dates = "daily";
};
daemon.settings = {
"runtimes" = {
crun = { path = "${pkgs.crun}/bin/crun"; };
};
"default-runtime" = "crun";
};
2025-09-29 16:49:43 +02:00
};
2025-09-29 17:32:31 +02:00
2025-09-29 19:09:03 +02:00
users.users.gitlab-runner = {
isSystemUser = true;
home = "/var/lib/gitlab-runner";
createHome = true;
shell = pkgs.bashInteractive;
extraGroups = [ "docker" "wheel" ];
group = "gitlab-runner";
};
users.groups.gitlab-runner = { };
users.groups.docker = { };
2025-09-29 11:23:45 +02:00
environment.systemPackages = with pkgs; [
2025-09-29 17:32:31 +02:00
docker
2025-09-29 11:23:45 +02:00
git
2025-09-29 20:11:41 +02:00
crun
2025-09-30 19:43:18 +02:00
fuse-overlayfs
2025-09-29 11:23:45 +02:00
];
systemd.services."enable-linger-gitlab-runner" = {
description = "Enable linger for gitlab-runner";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.systemd}/bin/loginctl enable-linger gitlab-runner";
RemainAfterExit = true;
};
};
2025-09-29 17:32:31 +02:00
# GitLab Runner configured to use the local Docker daemon
2025-09-29 11:23:45 +02:00
services.gitlab-runner = {
enable = true;
2025-09-29 16:12:43 +02:00
services = {
2025-09-29 17:32:31 +02:00
ci-nspawn-docker = {
2025-09-29 16:12:43 +02:00
authenticationTokenConfigFile = "/var/lib/gitlab-runner/token-env";
2025-09-29 17:32:31 +02:00
executor = "docker";
2025-09-29 11:23:45 +02:00
dockerImage = "alpine:3";
2025-09-29 17:32:31 +02:00
dockerPrivileged = true;
2025-09-29 11:23:45 +02:00
dockerVolumes = [
"/var/lib/gitlab-runner/cache:/cache"
];
2025-09-29 17:32:31 +02:00
};
};
};
2025-09-29 18:01:37 +02:00
systemd.services.gitlab-runner.serviceConfig = {
StateDirectory = lib.mkForce "";
LogsDirectory = lib.mkForce "";
CacheDirectory = lib.mkForce "";
2025-09-29 18:10:56 +02:00
RuntimeDirectory = lib.mkForce "";
ProtectSystem = lib.mkForce "no";
ProtectHome = lib.mkForce "no";
ReadWritePaths = [ "/var/lib/gitlab-runner" ];
2025-09-29 18:01:37 +02:00
};
2025-09-29 17:32:31 +02:00
# Basics
systemd.oomd.enable = false;
2025-09-29 11:23:45 +02:00
services.dbus.enable = true;
2025-09-29 17:32:31 +02:00
};
2025-09-29 16:22:54 +02:00
}; # end containers.gitlab-runner
2025-09-29 17:32:31 +02:00
2025-08-12 21:00:01 +02:00
} # end file
2025-09-29 11:23:45 +02:00