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 { sub process {
my ($self, $c) = @_; my ($self, $c) = @_;
my $res = "[\n"; my %perSystem;
foreach my $pkg (@{$c->stash->{nixPkgs}}) { foreach my $pkg (@{$c->stash->{nixPkgs}}) {
my $build = $pkg->{build}; my $build = $pkg->{build};
$res .= " # $pkg->{name}\n"; my $s = "";
$res .= " { type = \"derivation\";\n"; $s .= " # $pkg->{name}\n";
$res .= " name = " . escape ($build->get_column("releasename") or $build->nixname) . ";\n"; $s .= " ${\escape $build->get_column('job')} = {\n";
$res .= " system = " . (escape $build->system) . ";\n"; $s .= " type = \"derivation\";\n";
$res .= " outPath = " . (escape $pkg->{outPath}) . ";\n"; $s .= " name = ${\escape ($build->get_column('releasename') or $build->nixname)};\n";
$res .= " meta = {\n"; $s .= " system = ${\escape $build->system};\n";
$res .= " description = " . (escape $build->description) . ";\n" $s .= " outPath = ${\escape $pkg->{outPath}};\n";
$s .= " meta = {\n";
$s .= " description = ${\escape $build->description};\n"
if $build->description; if $build->description;
$res .= " longDescription = " . (escape $build->longdescription) . ";\n" $s .= " longDescription = ${\escape $build->longdescription};\n"
if $build->longdescription; if $build->longdescription;
$res .= " license = " . (escape $build->license) . ";\n" $s .= " license = ${\escape $build->license};\n"
if $build->license; if $build->license;
$res .= " };\n"; $s .= " maintainers = ${\escape $build->maintainers};\n"
$res .= " }\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; my $tar = Archive::Tar->new;
$tar->add_data("channel/channel-name", ($c->stash->{channelName} or "unnamed-channel"), {mtime => 0}); $tar->add_data("channel/channel-name", ($c->stash->{channelName} or "unnamed-channel"), {mtime => 1});
$tar->add_data("channel/default.nix", $res, {mtime => 0}); $tar->add_data("channel/default.nix", $res, {mtime => 1});
my $tardata = $tar->write; my $tardata = $tar->write;
my $bzip2data; my $bzip2data;