nixos-config/hosts/x86_64-linux/beleth/git.nix

100 lines
3.3 KiB
Nix
Raw Normal View History

2024-05-16 19:00:47 +02:00
{
2024-06-09 20:48:07 +02:00
lib,
2024-07-11 15:28:28 +02:00
config,
2024-06-09 20:48:07 +02:00
inputs,
2024-07-11 15:28:28 +02:00
pkgs,
2024-06-09 20:48:07 +02:00
...
2024-07-11 15:28:28 +02:00
}: let
gitea-actions-runner-custom = import ./services/gitea-runner.nix;
in {
imports = [gitea-actions-runner-custom];
2024-07-11 15:28:28 +02:00
# config = { services.gitea-actions-runner = gitea-actions-runner-custom.config.services.gitea-actions-runner; };
sops.secrets.forgejo_runner_token = {
owner = "forgejo";
group = "forgejo";
mode = "0444";
};
2024-05-16 19:00:47 +02:00
services.forgejo = {
enable = true;
2024-05-16 19:06:02 +02:00
settings.server = {
2024-05-16 19:08:16 +02:00
HTTP_PORT = 3002;
2024-05-16 19:15:20 +02:00
ROOT_URL = "https://git.heroin.trade";
2024-05-16 19:06:02 +02:00
};
2024-05-16 19:22:28 +02:00
settings = {
service = {
2024-06-09 20:48:07 +02:00
DISABLE_REGISTRATION = true;
2024-07-11 15:28:28 +02:00
# REQUIRE_SIGNIN_VIEW = true;
2024-06-21 10:31:55 +02:00
};
2024-06-21 15:52:48 +02:00
DEFAULT = {
2024-07-01 20:45:31 +02:00
APP_NAME = "Git so good it could be heroin";
};
metrics = {
ENABLED = true;
2024-05-16 19:22:28 +02:00
};
};
2024-05-16 19:00:47 +02:00
};
2024-07-11 15:28:28 +02:00
services.gitea-actions-runner-custom = {
package = pkgs.forgejo-actions-runner;
instances.default = {
enable = true;
name = "monolith";
url = "https://git.heroin.trade";
token = "";
labels = [
"ubuntu-latest:docker://node:16-bullseye"
"ubuntu-22.04:docker://node:16-bullseye"
"ubuntu-20.04:docker://node:16-bullseye"
"ubuntu-18.04:docker://node:16-buster"
"native:host"
2024-07-11 15:28:28 +02:00
];
hostPackages = with pkgs; [
bash
coreutils
curl
gawk
gitMinimal
gnused
nodejs
wget
];
};
};
# systemd.services.gitea-runner-default = {
# preStart = lib.mkForce ''
# export INSTANCE_DIR="$STATE_DIRECTORY/default"
# export TOKEN="$(cat /run/secrets/forgejo_runner_token)"
# mkdir -vp "$INSTANCE_DIR"
# cd "$INSTANCE_DIR"
#
# # force reregistration on changed labels
# export LABELS_FILE="$INSTANCE_DIR/.labels"
# # export LABELS_WANTED="$(echo 'ubuntu-latest:docker://node:16-bullseye
# # ubuntu-22.04:docker://node:16-bullseye
# # ubuntu-20.04:docker://node:16-bullseye
# # ubuntu-18.04:docker://node:16-buster' | sort)"
# export LABELS_WANTED="$(echo ${lib.strings.concatStrings config.services.gitea-actions-runner.instances.default.labels} | sort)"
# export LABELS_CURRENT="$(cat $LABELS_FILE 2>/dev/null || echo 0)"
#
# if [ ! -e "$INSTANCE_DIR/.runner" ] || [ "$LABELS_WANTED" != "$LABELS_CURRENT" ]; then
# # remove existing registration file, so that changing the labels forces a re-registration
# rm -v "$INSTANCE_DIR/.runner" || true
#
# # perform the registration
# /nix/store/z3v4091wwdhdb60m72k0pxkim8q7chrk-forgejo-runner-3.5.0/bin/act_runner register --no-interactive \
# --instance 'https://git.heroin.trade' \
# --token "$TOKEN" \
# --name 'monolith' \
# --labels 'ubuntu-latest:docker://node:16-bullseye,ubuntu-22.04:docker://node:16-bullseye,ubuntu-20.04:docker://node:16-bullseye,ubuntu-18.04:docker://node:16-buster' \
# --config /nix/store/99q15qaajdi7rqz4bxbmhpkch2v8wg4f-config.yaml
#
# # and write back the configured labels
# echo "$LABELS_WANTED" > "$LABELS_FILE"
# fi
# '';
# serviceConfig.DynamicUser = lib.mkForce false;
# serviceConfig.User = lib.mkForce "forgejo";
# serviceConfig.Group = lib.mkForce "forgejo";
# };
environment.systemPackages = with pkgs; [forgejo-runner];
2024-05-16 19:00:47 +02:00
}