1919 TypedDict ,
2020)
2121
22+ System = Literal ["x86_64-linux" , "aarch64-linux" , "aarch64-darwin" ]
23+ RunnerType = Literal ["ephemeral" , "self-hosted" ]
24+
2225
2326class NixEvalJobsOutput (TypedDict ):
2427 """Raw output from nix-eval-jobs command."""
@@ -27,9 +30,8 @@ class NixEvalJobsOutput(TypedDict):
2730 attrPath : List [str ]
2831 cacheStatus : Literal ["notBuilt" , "cached" , "local" ]
2932 drvPath : str
30- isCached : bool
3133 name : str
32- system : str
34+ system : System
3335 neededBuilds : NotRequired [List [Any ]]
3436 neededSubstitutes : NotRequired [List [Any ]]
3537 outputs : NotRequired [Dict [str , str ]]
@@ -48,21 +50,29 @@ class GitHubActionPackage(TypedDict):
4850
4951 attr : str
5052 name : str
51- system : str
53+ system : System
5254 runs_on : RunsOnConfig
5355 postgresql_version : NotRequired [str ]
5456
5557
56- BUILD_RUNNER_MAP : Dict [str , RunsOnConfig ] = {
57- "aarch64-linux" : {
58- "labels" : ["blacksmith-8vcpu-ubuntu-2404-arm" ],
59- },
60- "aarch64-darwin" : {
61- "group" : "self-hosted-runners-nix" ,
62- "labels" : ["aarch64-darwin" ],
58+ BUILD_RUNNER_MAP : Dict [RunnerType , Dict [System , RunsOnConfig ]] = {
59+ "ephemeral" : {
60+ "aarch64-linux" : {
61+ "labels" : ["blacksmith-8vcpu-ubuntu-2404-arm" ],
62+ },
63+ "x86_64-linux" : {
64+ "labels" : ["blacksmith-8vcpu-ubuntu-2404" ],
65+ },
6366 },
64- "x86_64-linux" : {
65- "labels" : ["blacksmith-8vcpu-ubuntu-2404" ],
67+ "self-hosted" : {
68+ "aarch64-darwin" : {
69+ "group" : "self-hosted-runners-nix" ,
70+ "labels" : ["aarch64-darwin" ],
71+ },
72+ "aarch64-linux" : {
73+ "group" : "self-hosted-runners-nix" ,
74+ "labels" : ["aarch64-linux" ],
75+ },
6676 },
6777}
6878
@@ -76,6 +86,7 @@ def build_nix_eval_command(max_workers: int, flake_outputs: List[str]) -> List[s
7686 "--check-cache-status" ,
7787 "--force-recurse" ,
7888 "--quiet" ,
89+ "--show-required-system-features" ,
7990 "--option" ,
8091 "eval-cache" ,
8192 "false" ,
@@ -171,19 +182,33 @@ def is_large_pkg(pkg: NixEvalJobsOutput) -> bool:
171182 )
172183
173184
174- def get_runner_for_package (pkg : NixEvalJobsOutput ) -> RunsOnConfig :
175- """Determine the appropriate GitHub Actions runner for a package."""
185+ def is_kvm_pkg (pkg : NixEvalJobsOutput ) -> bool :
186+ """Determine if a package requires KVM"""
187+ return "kvm" in pkg .get ("requiredSystemFeatures" , [])
188+
189+
190+ def get_runner_for_package (pkg : NixEvalJobsOutput ) -> RunsOnConfig | None :
191+ """Determine the appropriate GitHub Actions runner for a package.
192+
193+ Priority order:
194+ 1. KVM packages → self-hosted runners
195+ 2. Large packages on Linux → 32vcpu ephemeral runners
196+ 3. Darwin packages → self-hosted runners
197+ 4. Default → ephemeral runners
198+ """
176199 system = pkg ["system" ]
177- if is_large_pkg (pkg ):
178- # Use larger runners for large packages for x86_64-linux and aarch64-linux
179- if system == "x86_64-linux" :
180- return {"labels" : ["blacksmith-32vcpu-ubuntu-2404" ]}
181- elif system == "aarch64-linux" :
182- return {"labels" : ["blacksmith-32vcpu-ubuntu-2404-arm" ]}
183- if system in BUILD_RUNNER_MAP :
184- return BUILD_RUNNER_MAP [system ]
185- else :
186- raise ValueError (f"No runner configuration for system: { system } " )
200+
201+ if is_kvm_pkg (pkg ):
202+ return BUILD_RUNNER_MAP ["self-hosted" ].get (system )
203+
204+ if is_large_pkg (pkg ) and system in ("x86_64-linux" , "aarch64-linux" ):
205+ suffix = "-arm" if system == "aarch64-linux" else ""
206+ return {"labels" : [f"blacksmith-32vcpu-ubuntu-2404{ suffix } " ]}
207+
208+ if system == "aarch64-darwin" :
209+ return BUILD_RUNNER_MAP ["self-hosted" ]["aarch64-darwin" ]
210+
211+ return BUILD_RUNNER_MAP ["ephemeral" ].get (system )
187212
188213
189214def main () -> None :
@@ -204,11 +229,14 @@ def main() -> None:
204229
205230 def clean_package_for_output (pkg : NixEvalJobsOutput ) -> GitHubActionPackage :
206231 """Convert nix-eval-jobs output to GitHub Actions matrix package"""
232+ runner = get_runner_for_package (pkg )
233+ if runner is None :
234+ raise ValueError (f"No runner configuration for system: { pkg ['system' ]} " )
207235 returned_pkg : GitHubActionPackage = {
208236 "attr" : pkg ["attr" ],
209237 "name" : pkg ["name" ],
210238 "system" : pkg ["system" ],
211- "runs_on" : get_runner_for_package ( pkg ) ,
239+ "runs_on" : runner ,
212240 }
213241 if is_extension_pkg (pkg ):
214242 # Extract PostgreSQL version from attribute path
0 commit comments