nixos_config/hosts/tesla-nixos/configuration.nix

122 lines
3.3 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-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;
hostAddress = "10.250.0.1"; # host end of veth
localAddress = "10.250.0.2"; # container end of veth
2025-09-29 11:23:45 +02:00
bindMounts = {
"/var/lib/gitlab-runner" = {
hostPath = "/var/lib/gitlab-runner";
isReadOnly = false;
};
};
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 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
];
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