{
  config,
  lib,
  pkgs,
  fetchFromGitHub,
  ...
}:
let
  cfg = config.modules.remoteBuild;
in
{
  options.modules.remoteBuild = {
    use-remote-builders = lib.mkEnableOption "remoteBuild";
  };
  config = lib.mkIf cfg.use-remote-builders {
    nix.package = pkgs.nix;
    nix.distributedBuilds = true;
    nix.settings.builders-use-substitutes = true;

    # Define every build machine here..
    nix.buildMachines = [
      {
        # Main desktop pc
        # ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKqsFEgtcTDw89GaZJg8P/FE1xngIXmiUZl8j0b+V7n+ root@doloroo-main
        hostName = "doloroo-main";
        sshUser = "remotebuild";
        sshKey = "/root/.ssh/remotebuild";
        # protocol = "ssh-ng";
        maxJobs = 8;
        speedFactor = 2;
        supportedFeatures = [
          "nixos-test"
          "big-parallel"
          "kvm"
        ];
      }
    ];
  };
}
