This repository has no description
2.4 kB
70 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 # ci-farm push PATH... pushes the closures of PATH... to niks3
46 #
47 # Runs in .github/workflows/farm.yml. See ci-farm.sh for the layout.
48 packages = lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
49 ci-farm = pkgs.writeShellApplication {
50 name = "ci-farm";
51 runtimeInputs = [
52 grpc.default
53 inputs.niks3.packages.${system}.niks3
54 pkgs.coreutils
55 pkgs.curl
56 pkgs.dumbpipe
57 pkgs.envoy-bin
58 pkgs.gh
59 pkgs.jq
60 ];
61 runtimeEnv = {
62 FARM_CRT = ./farm.crt;
63 ENVOY_CONFIG = envoyConfig;
64 NIX_WITH_PLUGIN = lib.getExe grpc.nix-with-plugin;
65 };
66 text = builtins.readFile ./ci-farm.sh;
67 };
68 };
69 };
70}