# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
#
# SPDX-License-Identifier: Apache-2.0

{ lib, config, ... }:
{
  imports = [ ./nixbuild-key.nix ];

  # Distributed builds!
  nix.buildMachines = lib.mkAfter [ {
    hostName = "whitby-build";
    system = "x86_64-linux";
    maxJobs = 64;
    speedFactor = 4;
    supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ];
    mandatoryFeatures = [ ];
  }];
  nix.distributedBuilds = true;

  programs.ssh.extraConfig = ''
    Host whitby-build
      Hostname whitby.tvl.fyi
      User lukegb
      PubkeyAcceptedKeyTypes ssh-ed25519
      IdentityFile ${config.my.vault.secrets.id_ed25519_nixbuild.path}
  '';
  programs.ssh.knownHosts = {
    whitby-build = {
      hostNames = [ "whitby.tvl.fyi" "whitby-build" ];
      publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILNh/w4BSKov0jdz3gKBc98tpoLta5bb87fQXWBhAl2I";
    };
  };
}