summaryrefslogtreecommitdiff
path: root/modules/nixos/custom/remote-builders.nix
blob: 74d05380366fd2613cbc75d031672cb78a2ed9c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{
  config,
  lib,
  secretsDir,
  ...
}:

let
  cfg = config.borealis.remote-builders;
in

{
  options.borealis.remote-builders = {
    enable = lib.mkEnableOption "the use of remote builders";

    manageSecrets = lib.mkEnableOption "automatic management of SSH keys for builders" // {
      default = true;
    };

    builders = {
      atlas = lib.mkEnableOption "`atlas` as a remote builder";
      macstadium = lib.mkEnableOption "`macstadium` as a remote builder";
    };
  };

  config = lib.mkIf cfg.enable (
    lib.mkMerge [
      {
        nix = {
          distributedBuilds = true;

          settings = {
            builders-use-substitutes = true;
          };
        };
      }

      (lib.mkIf cfg.builders.atlas {
        nix.buildMachines = [
          {
            hostName = "atlas";
            maxJobs = 4;
            publicHostKey = "IyBhdGxhczoyMiBTU0gtMi4wLVRhaWxzY2FsZQphdGxhcyBzc2gtZWQyNTUxOSBBQUFBQzNOemFDMWxaREkxTlRFNUFBQUFJQzdZaVNZWXgvK3ptVk9QU0NFUkh6U3NNZVVRdEErVnQxVzBzTFV3NFloSwo=";
            sshUser = "atlas";
            supportedFeatures = [
              "benchmark"
              "big-parallel"
              "gccarch-armv8-a"
              "kvm"
              "nixos-test"
            ];
            systems = [
              "aarch64-linux"
            ];
          }
        ];
      })

      (lib.mkIf cfg.builders.macstadium {
        nix.buildMachines = [
          (lib.mkMerge [
            {
              hostName = "mini.scrumplex.net";
              maxJobs = 8;
              publicHostKey = "IyBtaW5pLnNjcnVtcGxleC5uZXQ6MjIgU1NILTIuMC1PcGVuU1NIXzkuOAptaW5pLnNjcnVtcGxleC5uZXQgc3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSU9DV1lXL29TbW5GYU1sOGQ0eHNjaGhxNkNKZkdjQ1M4djhLYkErb0dmQ3IK";
              sshUser = "bob-the-builder";
              supportedFeatures = [
                "nixos-test"
                "benchmark"
                "big-parallel"
                "apple-virt"
              ];
              systems = [
                "aarch64-darwin"
                "x86_64-darwin"
              ];
            }

            (lib.mkIf cfg.manageSecrets {
              sshKey = config.age.secrets.macstadium.path;
            })
          ])
        ];
      })

      (lib.mkIf (cfg.manageSecrets && cfg.builders.macstadium) {
        age.secrets = {
          macstadium = {
            file = secretsDir + "/macstadium.age";
            mode = "600";
          };
        };
      })
    ]
  );
}