···4455This requires macOS version 12.4 or later.
6677-This also requires that port 22 on your machine is free (since Nix does not
88-permit specifying a non-default SSH port for builders).
99-107You will also need to be a trusted user for your Nix installation. In other
118words, your `/etc/nix/nix.conf` should have something like:
129···5047```
5148# - Replace ${ARCH} with either aarch64 or x86_64 to match your host machine
5249# - Replace ${MAX_JOBS} with the maximum number of builds (pick 4 if you're not sure)
5353-builders = ssh-ng://builder@localhost ${ARCH}-linux /etc/nix/builder_ed25519 ${MAX_JOBS} - - - c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo=
5050+builders = ssh-ng://builder@linux-builder ${ARCH}-linux /etc/nix/builder_ed25519 ${MAX_JOBS} - - - c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo=
54515552# Not strictly necessary, but this will reduce your disk utilization
5653builders-use-substitutes = true
5454+```
5555+5656+To allow Nix to connect to a builder not running on port 22, you will also need to create a new file at `/etc/ssh/ssh_config.d/100-linux-builder.conf`:
5757+5858+```
5959+Host linux-builder
6060+ Hostname localhost
6161+ HostKeyAlias linux-builder
6262+ Port 31022
5763```
58645965… and then restart your Nix daemon to apply the change:
+5-5
nixos/modules/profiles/macos-builder.nix
···11-{ config, lib, pkgs, ... }:
11+{ config, lib, ... }:
2233let
44 keysDirectory = "/var/keys";
···6767 '';
6868 };
6969 hostPort = mkOption {
7070- default = 22;
7070+ default = 31022;
7171 type = types.int;
7272- example = 31022;
7272+ example = 22;
7373 description = ''
7474 The localhost host port to forward TCP to the guest port.
7575 '';
···139139140140 hostPkgs = config.virtualisation.host.pkgs;
141141142142- script = hostPkgs.writeShellScriptBin "create-builder" (
142142+ script = hostPkgs.writeShellScriptBin "create-builder" (
143143 # When running as non-interactively as part of a DarwinConfiguration the working directory
144144 # must be set to a writeable directory.
145145 (if cfg.workingDirectory != "." then ''
146146 ${hostPkgs.coreutils}/bin/mkdir --parent "${cfg.workingDirectory}"
147147 cd "${cfg.workingDirectory}"
148148- '' else "") + ''
148148+ '' else "") + ''
149149 KEYS="''${KEYS:-./keys}"
150150 ${hostPkgs.coreutils}/bin/mkdir --parent "''${KEYS}"
151151 PRIVATE_KEY="''${KEYS}/${user}_${keyType}"