forked from lix-project/hydra
* Generate a Nix expression for the channel.
This commit is contained in:
parent
f75924db95
commit
7ffb32e048
|
@ -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;
|
||||||
|
|
|
@ -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];
|
||||||
|
|
40
src/Hydra/lib/Hydra/View/NixExprs.pm
Normal file
40
src/Hydra/lib/Hydra/View/NixExprs.pm
Normal 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;
|
Loading…
Reference in a new issue