From 35cd963f8c805e645a96460826ce972a60e3d8f1 Mon Sep 17 00:00:00 2001 From: hexchen Date: Wed, 18 Aug 2021 17:08:24 +0000 Subject: [PATCH] services/gitlab-runner: init on parsons also disable ci for hainich --- .gitlab-ci.yml | 7 ---- hosts/parsons/configuration.nix | 8 +++++ hosts/parsons/hardware.nix | 5 +++ modules/nftnat/default.nix | 4 +-- pkgs/default.nix | 4 ++- services/gitlab-runner.nix | 63 +++++++++++++++++++++++++++++++++ 6 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 services/gitlab-runner.nix diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a3f0205..6e67dcc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,10 +14,3 @@ build-nixda: stage: build script: - nix-build -A deploy.nixda - -build-hainich: - tags: - - nix - stage: build - script: - - nix-build -A deploy.hainich diff --git a/hosts/parsons/configuration.nix b/hosts/parsons/configuration.nix index a5cab21..f7efc33 100644 --- a/hosts/parsons/configuration.nix +++ b/hosts/parsons/configuration.nix @@ -18,6 +18,7 @@ ../../services/syncthing.nix ../../services/gitlab.nix ../../services/nginx-pages.nix + ../../services/gitlab-runner.nix ./lxc.nix ]; @@ -48,6 +49,13 @@ address = "fe80::1"; interface = "enp35s0"; }; + boot = { + kernelModules = [ "nf_nat_ftp" ]; + kernel.sysctl = { + "net.ipv4.conf.all.forwarding" = lib.mkOverride 90 true; + "net.ipv4.conf.default.forwarding" = lib.mkOverride 90 true; + }; + }; services.nginx = { enable = true; diff --git a/hosts/parsons/hardware.nix b/hosts/parsons/hardware.nix index 36c90bb..e71bcca 100644 --- a/hosts/parsons/hardware.nix +++ b/hosts/parsons/hardware.nix @@ -55,6 +55,11 @@ fsType = "zfs"; }; + fileSystems."/var/lib/docker" = + { device = "zroot/local/docker"; + fsType = "zfs"; + }; + swapDevices = [ ]; } diff --git a/modules/nftnat/default.nix b/modules/nftnat/default.nix index b3fc2c2..e5481f5 100644 --- a/modules/nftnat/default.nix +++ b/modules/nftnat/default.nix @@ -36,8 +36,8 @@ in { boot = { kernelModules = [ "nf_nat_ftp" ]; kernel.sysctl = { - "net.ipv4.conf.all.forwarding" = mkOverride 98 true; - "net.ipv4.conf.default.forwarding" = mkOverride 98 true; + "net.ipv4.conf.all.forwarding" = mkOverride 90 true; + "net.ipv4.conf.default.forwarding" = mkOverride 90 true; }; }; diff --git a/pkgs/default.nix b/pkgs/default.nix index ea59e11..703ea98 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -11,7 +11,9 @@ let alps = callPackage ./alps {}; docker = pkgs.docker.overrideAttrs (super: { - extraPath = super.extraPath + ":${pkgs.zfs}/bin"; + moby = super.moby.overrideAttrs (super: { + extraPath = super.extraPath + ":${pkgs.zfs}/bin"; + }); }); linuxPackagesFor = kernel: (pkgs.linuxPackagesFor kernel).extend (_: ksuper: { diff --git a/services/gitlab-runner.nix b/services/gitlab-runner.nix new file mode 100644 index 0000000..6968d1c --- /dev/null +++ b/services/gitlab-runner.nix @@ -0,0 +1,63 @@ +{config, pkgs, lib, ...}: + +{ + services.gitlab-runner = { + enable = true; + concurrent = 4; + services = { + infra4future = { + buildsDir = "/persist/var/lib/gitlab-runner/builds"; + dockerImage = "nixos/nix"; + executor = "docker"; + registrationConfigFile = "/persist/var/lib/gitlab-runner/gitlab-runner.env"; + }; + nix = { + limit = 1; # don't run multiple jobs + registrationConfigFile = "/persist/var/lib/gitlab-runner/gitlab-runner.env"; + dockerImage = "alpine"; + dockerVolumes = [ + "/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 + ${pkgs.nix}/bin/nix-env -i ${lib.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 + ''; + 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" ]; + }; + }; + }; + + systemd.services.gitlab-runner.serviceConfig = { + DynamicUser = lib.mkForce false; + User = "gitlab-runner"; + }; + + users.users.gitlab-runner = { + home = "/persist/var/lib/gitlab-runner"; + extraGroups = [ "docker" ]; + isSystemUser = true; + }; + + virtualisation.docker.storageDriver = "zfs"; +}