nixos-config/system/monolith-gitlab-runner.nix

66 lines
2.6 KiB
Nix
Raw Normal View History

2022-10-06 12:49:48 -03:00
{ config, pkgs, lib, ... }: {
boot.kernel.sysctl."net.ipv4.ip_forward" = true;
virtualisation.docker.enable = true;
2022-12-02 14:40:11 -03:00
services.gitlab-runner = {
2022-10-06 12:49:48 -03:00
enable = true;
2022-12-02 14:40:11 -03:00
settings.concurrent = 4;
2022-10-06 12:49:48 -03:00
services = {
2022-12-23 11:22:58 -03:00
# ci_test = {
# registrationConfigFile = "/srv/gitlab-runner/env/ci_test";
# dockerImage = "debian";
# dockerPrivileged = true;
# };
2022-10-06 12:49:48 -03:00
thoreb_builder = {
2022-12-23 11:22:58 -03:00
registrationConfigFile = config.age.secrets.monolith-gitlab-runner-thoreb-itinerario-registrationConfigFile.path;
2022-10-06 12:49:48 -03:00
dockerImage = "debian";
dockerPrivileged = true;
2022-10-06 12:49:48 -03:00
};
2023-02-24 12:37:35 -03:00
# runner for building in docker via host's nix-daemon
# nix store will be readable in runner, might be insecure
nix = with lib; rec {
2023-02-24 12:37:35 -03:00
# File should contain at least these two variables:
# `CI_SERVER_URL`
# `REGISTRATION_TOKEN`
registrationConfigFile = config.age.secrets.gitlab-runner-thoreb-telemetria-registrationConfigFile.path; # 2
dockerImage = "alpine:3.18.2";
dockerAllowedImages = [ dockerImage ];
2023-02-24 12:37:35 -03:00
dockerVolumes = [
"/etc/nix/nix.conf:/etc/nix/nix.conf:ro"
2023-02-24 12:37:35 -03:00
"/nix/store:/nix/store:ro"
"/nix/var/nix/db:/nix/var/nix/db:ro"
"/nix/var/nix/daemon-socket:/nix/var/nix/daemon-socket:ro"
];
dockerDisableCache = true;
preBuildScript = pkgs.writeScript "setup-container" ''
mkdir -p -m 0755 /nix/var/log/nix/drvs
mkdir -p -m 0755 /nix/var/nix/gcroots
mkdir -p -m 0755 /nix/var/nix/profiles
mkdir -p -m 0755 /nix/var/nix/temproots
mkdir -p -m 0755 /nix/var/nix/userpool
mkdir -p -m 1777 /nix/var/nix/gcroots/per-user
mkdir -p -m 1777 /nix/var/nix/profiles/per-user
mkdir -p -m 0755 /nix/var/nix/profiles/per-user/root
mkdir -p -m 0700 "$HOME/.nix-defexpr"
. ${pkgs.nix}/etc/profile.d/nix.sh
2023-02-24 12:37:35 -03:00
${pkgs.nix}/bin/nix-env -i ${concatStringsSep " " (with pkgs; [ nix cacert git openssh ])}
${pkgs.nix}/bin/nix-channel --add https://nixos.org/channels/nixpkgs-unstable
${pkgs.nix}/bin/nix-channel --update nixpkgs
2023-02-24 12:37:35 -03:00
'';
environmentVariables = {
ENV = "/etc/profile";
USER = "root";
NIX_REMOTE = "daemon";
PATH = "/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin:/bin:/sbin:/usr/bin:/usr/sbin";
NIX_SSL_CERT_FILE = "/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt";
};
tagList = [ "nix" ];
};
2022-10-06 12:49:48 -03:00
};
};
2022-11-05 09:48:46 -03:00
systemd.services.gitlab-runner.serviceConfig.Nice = 10;
2022-10-06 12:49:48 -03:00
}