In Hydra channels, show only packages matching the user's system type

Fixes NixOS/nix#169.
This commit is contained in:
Eelco Dolstra 2013-10-07 14:53:27 +02:00
parent 5294a0a8a0
commit 5ccff14f6b

View file

@ -19,31 +19,48 @@ sub escape {
sub process {
my ($self, $c) = @_;
my $res = "[\n";
my %perSystem;
foreach my $pkg (@{$c->stash->{nixPkgs}}) {
my $build = $pkg->{build};
$res .= " # $pkg->{name}\n";
$res .= " { type = \"derivation\";\n";
$res .= " name = " . escape ($build->get_column("releasename") or $build->nixname) . ";\n";
$res .= " system = " . (escape $build->system) . ";\n";
$res .= " outPath = " . (escape $pkg->{outPath}) . ";\n";
$res .= " meta = {\n";
$res .= " description = " . (escape $build->description) . ";\n"
my $s = "";
$s .= " # $pkg->{name}\n";
$s .= " ${\escape $build->get_column('job')} = {\n";
$s .= " type = \"derivation\";\n";
$s .= " name = ${\escape ($build->get_column('releasename') or $build->nixname)};\n";
$s .= " system = ${\escape $build->system};\n";
$s .= " outPath = ${\escape $pkg->{outPath}};\n";
$s .= " meta = {\n";
$s .= " description = ${\escape $build->description};\n"
if $build->description;
$res .= " longDescription = " . (escape $build->longdescription) . ";\n"
$s .= " longDescription = ${\escape $build->longdescription};\n"
if $build->longdescription;
$res .= " license = " . (escape $build->license) . ";\n"
$s .= " license = ${\escape $build->license};\n"
if $build->license;
$res .= " };\n";
$res .= " }\n";
$s .= " maintainers = ${\escape $build->maintainers};\n"
if $build->maintainers;
$s .= " };\n";
$s .= " };\n\n";
$perSystem{$build->system} .= $s;
}
$res .= "]\n";
my $res = "{ system ? builtins.currentSystem }:\n\n";
my $first = 1;
foreach my $system (keys %perSystem) {
$res .= "else " if !$first;
$res .= "if system == ${\escape $system} then {\n\n";
$res .= $perSystem{$system};
$res .= "}\n\n";
$first = 0;
}
$res .= "else " if !$first;
$res .= "{}\n";
my $tar = Archive::Tar->new;
$tar->add_data("channel/channel-name", ($c->stash->{channelName} or "unnamed-channel"), {mtime => 0});
$tar->add_data("channel/default.nix", $res, {mtime => 0});
$tar->add_data("channel/channel-name", ($c->stash->{channelName} or "unnamed-channel"), {mtime => 1});
$tar->add_data("channel/default.nix", $res, {mtime => 1});
my $tardata = $tar->write;
my $bzip2data;