darwin.builder: use port 31022 by default

Changed files
+15 -9
doc
builders
nixos
modules
+10 -4
doc/builders/special/darwin-builder.section.md
···
This requires macOS version 12.4 or later.
-
This also requires that port 22 on your machine is free (since Nix does not
-
permit specifying a non-default SSH port for builders).
-
You will also need to be a trusted user for your Nix installation. In other
words, your `/etc/nix/nix.conf` should have something like:
···
```
# - Replace ${ARCH} with either aarch64 or x86_64 to match your host machine
# - Replace ${MAX_JOBS} with the maximum number of builds (pick 4 if you're not sure)
-
builders = ssh-ng://builder@localhost ${ARCH}-linux /etc/nix/builder_ed25519 ${MAX_JOBS} - - - c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo=
+
builders = ssh-ng://builder@linux-builder ${ARCH}-linux /etc/nix/builder_ed25519 ${MAX_JOBS} - - - c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo=
# Not strictly necessary, but this will reduce your disk utilization
builders-use-substitutes = true
+
```
+
+
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`:
+
+
```
+
Host linux-builder
+
Hostname localhost
+
HostKeyAlias linux-builder
+
Port 31022
```
… and then restart your Nix daemon to apply the change:
+5 -5
nixos/modules/profiles/macos-builder.nix
···
-
{ config, lib, pkgs, ... }:
+
{ config, lib, ... }:
let
keysDirectory = "/var/keys";
···
'';
};
hostPort = mkOption {
-
default = 22;
+
default = 31022;
type = types.int;
-
example = 31022;
+
example = 22;
description = ''
The localhost host port to forward TCP to the guest port.
'';
···
hostPkgs = config.virtualisation.host.pkgs;
-
script = hostPkgs.writeShellScriptBin "create-builder" (
+
script = hostPkgs.writeShellScriptBin "create-builder" (
# When running as non-interactively as part of a DarwinConfiguration the working directory
# must be set to a writeable directory.
(if cfg.workingDirectory != "." then ''
${hostPkgs.coreutils}/bin/mkdir --parent "${cfg.workingDirectory}"
cd "${cfg.workingDirectory}"
-
'' else "") + ''
+
'' else "") + ''
KEYS="''${KEYS:-./keys}"
${hostPkgs.coreutils}/bin/mkdir --parent "''${KEYS}"
PRIVATE_KEY="''${KEYS}/${user}_${keyType}"