* Generate a Nix expression for the channel.

This commit is contained in:
Eelco Dolstra 2009-03-02 17:17:36 +00:00
parent f75924db95
commit 7ffb32e048
3 changed files with 50 additions and 1 deletions

View file

@ -57,4 +57,10 @@ sub pkg : Chained('nix') PathPart Args(1) {
} }
sub nixexprs : Chained('nix') PathPart Args(0) {
my ($self, $c) = @_;
$c->stash->{current_view} = 'Hydra::View::NixExprs';
}
1; 1;

View file

@ -532,13 +532,16 @@ sub job :Local {
sub nix : Chained('/') PathPart('nix') CaptureArgs(0) { sub nix : Chained('/') PathPart('nix') CaptureArgs(0) {
my ($self, $c) = @_; my ($self, $c) = @_;
my @builds = getLatestBuilds($c, $c->model('DB::Builds')); my @builds = getLatestBuilds($c, $c->model('DB::Builds')); # !!! this includes failed builds
my @storePaths = (); my @storePaths = ();
foreach my $build (@builds) { foreach my $build (@builds) {
# !!! better do this in getLatestBuilds with a join. # !!! better do this in getLatestBuilds with a join.
next unless $build->buildproducts->find({type => "nix-build"}); next unless $build->buildproducts->find({type => "nix-build"});
push @storePaths, $build->outpath if isValidPath($build->outpath); push @storePaths, $build->outpath if isValidPath($build->outpath);
my $pkgName = $build->nixname . "-" . $build->system . "-" . $build->id . ".nixpkg";
$c->stash->{nixPkgs}->{$pkgName} = $build;
}; };
$c->stash->{storePaths} = [@storePaths]; $c->stash->{storePaths} = [@storePaths];

View file

@ -0,0 +1,40 @@
package Hydra::View::NixExprs;
use strict;
use base qw/Catalyst::View/;
use Hydra::Helper::Nix;
sub process {
my ($self, $c) = @_;
my $res = "[\n";
foreach my $name (keys %{$c->stash->{nixPkgs}}) {
my $build = $c->stash->{nixPkgs}->{$name};
$res .= " # $name\n";
$res .= " { type = \"derivation\";\n";
$res .= " name = \"" . ($build->resultInfo->releasename or $build->nixname) . "\";\n"; # !!! escaping?
$res .= " system = \"" . $build->system . "\";\n"; # idem
$res .= " outPath = " . $build->outpath . ";\n";
$res .= " meta = {\n";
$res .= " description = \"" . $build->description . "\";\n"
if $build->description;
$res .= " longDescription = \"" . $build->longdescription . "\";\n"
if $build->longdescription;
$res .= " license = \"" . $build->license . "\";\n"
if $build->license;
$res .= " };\n";
$res .= " }\n";
}
$res .= "]\n";
$c->response->content_type('text/plain');
$c->response->body($res);
return 1;
}
1;