Skip to content

Commit 18cfd54

Browse files
authored
Merge pull request #172 from booxter/nvws-as-builder
Register nvws as builder for work profiles
2 parents a395838 + e591200 commit 18cfd54

File tree

5 files changed

+65
-10
lines changed

5 files changed

+65
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ around `nixmoxer`).
159159
| --- | --- | --- | --- | --- |
160160
| `pi5` | NixOS (Raspberry Pi) | DHCP and network services for the lab. | [nixos/pi5/default.nix](nixos/pi5/default.nix) | [common](common), [nixos](nixos) |
161161
| `beast` | NixOS (x86_64-linux) | NAS storage + Jellyfin/Jellarr server. | [nixos/beast/default.nix](nixos/beast/default.nix) | [common](common), [nixos](nixos) |
162-
| `nvws` | Proxmox host | Work Proxmox node configuration. Single node. | [nixos/nvws/default.nix](nixos/nvws/default.nix) | [common](common), [nixos](nixos) |
162+
| `nvws` | Proxmox host | Work Proxmox node configuration. Single node. Also serves as a remote x86_64-linux builder for work machines. | [nixos/nvws/default.nix](nixos/nvws/default.nix) | [common](common), [nixos](nixos) |
163163
| `prx1-lab` | Proxmox host | Lab Proxmox node (cluster leader). | [nixos/prx1-lab/default.nix](nixos/prx1-lab/default.nix) | [common](common), [nixos](nixos) |
164164
| `prx2-lab` | Proxmox host | Lab Proxmox node (cluster member). | [nixos/prx2-lab/default.nix](nixos/prx2-lab/default.nix) | [common](common), [nixos](nixos) |
165165
| `prx3-lab` | Proxmox host | Lab Proxmox node (cluster member). | [nixos/prx3-lab/default.nix](nixos/prx3-lab/default.nix) | [common](common), [nixos](nixos) |
File renamed without changes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
lib,
3+
config,
4+
username,
5+
hostname,
6+
...
7+
}:
8+
{
9+
programs.ssh = {
10+
knownHosts = {
11+
"nvws.local" = {
12+
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHfcwsYERqU04xrr6LY0lcbkmlcFuThaURac/AlvP8mR";
13+
};
14+
};
15+
extraConfig =
16+
let
17+
identityFile = "${config.users.users.${username}.home}/.ssh/id_ed25519";
18+
user = "ihrachyshka";
19+
in
20+
''
21+
Host nvws.local
22+
Hostname nvws.local
23+
IdentityFile ${identityFile}
24+
User ${user}
25+
'';
26+
};
27+
28+
nix.buildMachines = lib.optional (hostname != "nvws") {
29+
hostName = "nvws.local";
30+
system = "x86_64-linux";
31+
protocol = "ssh-ng";
32+
maxJobs = 4;
33+
speedFactor = 100;
34+
supportedFeatures = [
35+
"nixos-test"
36+
"benchmark"
37+
"big-parallel"
38+
"kvm"
39+
];
40+
};
41+
42+
nix.settings.builders-use-substitutes = true;
43+
nix.distributedBuilds = true;
44+
}

common/default.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
}:
99
let
1010
canUseBuilders = !isWork && (hostname == "mair" || hostname == "mmini" || hostname == "frame");
11+
canUseWorkBuilders = isWork && hostname != "nvws";
1112
workKeys = [
1213
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHt25mSiJLQjx2JECMuhTZEV6rlrOYk3CT2cUEdXAoYs ihrachyshka@ihrachyshka-mlt"
1314
];
@@ -29,7 +30,10 @@ in
2930
]
3031
++ lib.optionals canUseBuilders [
3132
./_mixins/community-builders
32-
./_mixins/remote-builders
33+
./_mixins/personal-builders
34+
]
35+
++ lib.optionals canUseWorkBuilders [
36+
./_mixins/work-builders
3337
];
3438

3539
options.host.isWork = lib.mkOption {

scripts/update-machines.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,39 @@ SSH_HOST_OPTS=()
2626

2727
resolve_ssh_host() {
2828
local host="$1"
29-
local base_host
29+
local base_host ssh_lookup_host
3030
local ssh_config proxy_jump proxy_cmd
3131
local resolved
3232
base_host="$(resolve_base_host "$host")"
3333
SSH_HOST_OPTS=()
34+
ssh_lookup_host="$base_host"
3435

35-
ssh_config="$(ssh -G "$base_host" 2>/dev/null || true)"
36+
# Work hosts are accessed over mDNS because corporate DNS policy blocks use
37+
# of the LAN DNS server for these names.
38+
if [[ "$MODE" == "work" && "$ssh_lookup_host" != *.* && ! "$ssh_lookup_host" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
39+
ssh_lookup_host="${ssh_lookup_host}.local"
40+
fi
41+
42+
ssh_config="$(ssh -G "$ssh_lookup_host" 2>/dev/null || true)"
3643
proxy_jump="$(awk '$1=="proxyjump" {print $2; exit}' <<<"$ssh_config")"
3744
proxy_cmd="$(awk '$1=="proxycommand" {print $2; exit}' <<<"$ssh_config")"
3845
if [[ -n "$proxy_jump" && "$proxy_jump" != "none" ]]; then
39-
printf '%s' "$base_host"
46+
printf '%s' "$ssh_lookup_host"
4047
return
4148
fi
4249
if [[ -n "$proxy_cmd" && "$proxy_cmd" != "none" ]]; then
43-
printf '%s' "$base_host"
50+
printf '%s' "$ssh_lookup_host"
4451
return
4552
fi
4653

47-
resolved="$(dig +short +time=1 +tries=1 "@${LAN_DNS_SERVER}" "$base_host" A | head -n1)"
54+
resolved="$(dig +short +time=1 +tries=1 "@${LAN_DNS_SERVER}" "$ssh_lookup_host" A | head -n1)"
4855
if [[ -n "$resolved" ]]; then
49-
SSH_HOST_OPTS=(-o HostName="$resolved" -o HostKeyAlias="$base_host")
50-
printf '%s' "$base_host"
56+
SSH_HOST_OPTS=(-o HostName="$resolved" -o HostKeyAlias="$ssh_lookup_host")
57+
printf '%s' "$ssh_lookup_host"
5158
return
5259
fi
5360

54-
printf '%s' "$base_host"
61+
printf '%s' "$ssh_lookup_host"
5562
}
5663

5764
ssh_base_opts=(

0 commit comments

Comments
 (0)