19
19
TypedDict ,
20
20
)
21
21
22
+ System = Literal ["x86_64-linux" , "aarch64-linux" , "aarch64-darwin" ]
23
+ RunnerType = Literal ["ephemeral" , "self-hosted" ]
24
+
22
25
23
26
class NixEvalJobsOutput (TypedDict ):
24
27
"""Raw output from nix-eval-jobs command."""
@@ -27,9 +30,8 @@ class NixEvalJobsOutput(TypedDict):
27
30
attrPath : List [str ]
28
31
cacheStatus : Literal ["notBuilt" , "cached" , "local" ]
29
32
drvPath : str
30
- isCached : bool
31
33
name : str
32
- system : str
34
+ system : System
33
35
neededBuilds : NotRequired [List [Any ]]
34
36
neededSubstitutes : NotRequired [List [Any ]]
35
37
outputs : NotRequired [Dict [str , str ]]
@@ -48,21 +50,29 @@ class GitHubActionPackage(TypedDict):
48
50
49
51
attr : str
50
52
name : str
51
- system : str
53
+ system : System
52
54
runs_on : RunsOnConfig
53
55
postgresql_version : NotRequired [str ]
54
56
55
57
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
+ },
63
66
},
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
+ },
66
76
},
67
77
}
68
78
@@ -76,6 +86,7 @@ def build_nix_eval_command(max_workers: int, flake_outputs: List[str]) -> List[s
76
86
"--check-cache-status" ,
77
87
"--force-recurse" ,
78
88
"--quiet" ,
89
+ "--show-required-system-features" ,
79
90
"--option" ,
80
91
"eval-cache" ,
81
92
"false" ,
@@ -171,19 +182,33 @@ def is_large_pkg(pkg: NixEvalJobsOutput) -> bool:
171
182
)
172
183
173
184
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
+ """
176
199
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 )
187
212
188
213
189
214
def main () -> None :
@@ -204,11 +229,14 @@ def main() -> None:
204
229
205
230
def clean_package_for_output (pkg : NixEvalJobsOutput ) -> GitHubActionPackage :
206
231
"""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' ]} " )
207
235
returned_pkg : GitHubActionPackage = {
208
236
"attr" : pkg ["attr" ],
209
237
"name" : pkg ["name" ],
210
238
"system" : pkg ["system" ],
211
- "runs_on" : get_runner_for_package ( pkg ) ,
239
+ "runs_on" : runner ,
212
240
}
213
241
if is_extension_pkg (pkg ):
214
242
# Extract PostgreSQL version from attribute path
0 commit comments