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

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

  # Distributed builds!
  nix.buildMachines = lib.mkAfter [{
    hostName = "eu.nixbuild.net";
    system = "aarch64-linux";
    maxJobs = 100;
    speedFactor = 1;
    supportedFeatures = [ "benchmark" "big-parallel" ];
    mandatoryFeatures = [ ];
  } {
    hostName = "eu.nixbuild.net";
    system = "x86_64-linux";
    maxJobs = 100;
    speedFactor = 1;
    supportedFeatures = [ "benchmark" "big-parallel" ];
    mandatoryFeatures = [ ];
  }];
  nix.distributedBuilds = true;

  programs.ssh.extraConfig = ''
    Host eu.nixbuild.net
      PubkeyAcceptedKeyTypes ssh-ed25519
      IdentityFile ${config.my.vault.secrets.id_ed25519_nixbuild.path}
  '';
  programs.ssh.knownHosts = {
    nixbuild = {
      hostNames = [ "eu.nixbuild.net" ];
      publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPIQCZc54poJ8vqawd8TraNryQeJnvH1eLpIDgbiqymM";
    };
  };
}