This repository has no description
2.4 kB
69 lines
1{ inputs, ... }:
2{
3 perSystem =
4 {
5 lib,
6 pkgs,
7 system,
8 ...
9 }:
10 let
11 grpc = inputs.nix-grpc-store.packages.${system};
12
13 # Envoy as configured by nix-grpc-store's NixOS module, rendered for a
14 # plain Linux runner. Plaintext towards the local client, the farm
15 # identity towards the nodes (they verify it and grant it `trusted`, so
16 # it can read the builder list from the scheduler).
17 envoyConfig =
18 (pkgs.formats.json { }).generate "ci-farm-envoy.json"
19 (inputs.nixpkgs.lib.nixosSystem {
20 modules = [
21 inputs.nix-grpc-store.nixosModules.lb
22 {
23 nixpkgs.pkgs = pkgs;
24 services.nix-grpc-farm-lb = {
25 enable = true;
26 listen = "127.0.0.1:50051";
27 scheduler = "127.0.0.1:50052";
28 systems = [ system ];
29 # Written by ci-farm.sh. Envoy watches the directories of
30 # these files, so they must exist on the runner.
31 tls.upstream = {
32 certFile = "/tmp/ci-farm/farm.crt";
33 keyFile = "/tmp/ci-farm/farm.key";
34 caFile = "/tmp/ci-farm/farm.crt";
35 };
36 };
37 }
38 ];
39 }).config.services.envoy.settings;
40 in
41 {
42 # ci-farm farm MACHINE... scheduler + builder + balancer, builds the
43 # toplevels of MACHINE... through the farm
44 # ci-farm worker INDEX builder, until the farm job has finished
45 #
46 # Runs in .github/workflows/farm.yml. See ci-farm.sh for the layout.
47 packages = lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
48 ci-farm = pkgs.writeShellApplication {
49 name = "ci-farm";
50 runtimeInputs = [
51 grpc.default
52 inputs.niks3.packages.${system}.niks3
53 pkgs.coreutils
54 pkgs.curl
55 pkgs.dumbpipe
56 pkgs.envoy-bin
57 pkgs.gh
58 pkgs.jq
59 ];
60 runtimeEnv = {
61 FARM_CRT = ./farm.crt;
62 ENVOY_CONFIG = envoyConfig;
63 NIX_WITH_PLUGIN = lib.getExe grpc.nix-with-plugin;
64 };
65 text = builtins.readFile ./ci-farm.sh;
66 };
67 };
68 };
69}