@cryptotaxi247 / infra-1 / commits / cea00185

nixos-channel-scripts: allow disambugating products by regex pattern

When a build has multiple build products for the same time the script would previously bail out. Now we allow passing a regular expression to filter down the list of build products to only matching ones.

Martin Weinelt committed Jun 25, 2026 at 15:27 UTC cea00185c2699b2172c0a2a71c8a168840b5dbd0
1 file changed +15 -5
pkgs/nixos-channel-scripts/mirror-nixos-branch.pl
+15 -5
@@ -156,24 +156,34 @@ if ($bucketReleases && $bucketReleases->head_key("$releasePrefix")) {
156 }
157
158 sub downloadFile {
159 - my ($jobName, $dstName, $productType) = @_;
159 + my ($jobName, $dstName, $productType, $productPattern) = @_;
160
161 my $buildInfo = decode_json(fetch("$evalUrl/job/$jobName", 'application/json'));
162
163 my $products = ();
164 # Key the products by subtype.
165 foreach my $key (keys $buildInfo->{buildproducts}->%*) {
166 - my $subType = $buildInfo->{buildproducts}->{$key}->{subtype};
166 + my $product = $buildInfo->{buildproducts}->{$key};
167 + my $subType = $product->{subtype};
168 +
169 + next if defined $productPattern
170 + && $product->{path} !~ /$productPattern/;
171 +
172 if ($products->{$subType}) {
168 - die "Job $jobName has multiple products of the same subtype $subType.\nThis is a bad assumption from this script";
173 + if (defined $productPattern) {
174 + die "Job $jobName has multiple products of subtype $subType that match $productPattern.\nRefine the product regex pattern further to disambiguate.";
175 + } else {
176 + die "Job $jobName has multiple products of the same subtype $subType.\nPass a product regex pattern to disambiguate.";
177 + }
178 }
170 - $products->{$subType} = $buildInfo->{buildproducts}->{$key};
179 +
180 + $products->{$subType} = $product;
181 }
182 my $size = keys %{$products};
183
184 if ($size > 1 && !$productType) {
185 my $types = join(", ", keys %{$products});
176 - die "Job $jobName has $size build products. Select the right product by subtype [$types]";
186 + die "Job $jobName has $size build products. Select the right product by subtype [$types] and product match";
187 }
188
189 my $product;