Add support for Guile & Guix.
This commit is contained in:
@ -463,6 +463,11 @@ sub clone_submit : Chained('build') PathPart('clone/submit') Args(0) {
|
||||
|
||||
my ($nixExprPath, $nixExprInputName) = Hydra::Controller::Jobset::nixExprPathFromParams $c;
|
||||
|
||||
# When the expression is in a .scm file, assume it's a Guile + Guix
|
||||
# build expression.
|
||||
my $exprType =
|
||||
$c->request->params->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix";
|
||||
|
||||
my $jobName = trim $c->request->params->{"jobname"};
|
||||
error($c, "Invalid job name: $jobName") if $jobName !~ /^$jobNameRE$/;
|
||||
|
||||
@ -488,7 +493,7 @@ sub clone_submit : Chained('build') PathPart('clone/submit') Args(0) {
|
||||
error($c, $@) if $@;
|
||||
}
|
||||
|
||||
my ($jobs, $nixExprInput) = evalJobs($inputInfo, $nixExprInputName, $nixExprPath);
|
||||
my ($jobs, $nixExprInput) = evalJobs($inputInfo, $exprType, $nixExprInputName, $nixExprPath);
|
||||
|
||||
my $job;
|
||||
foreach my $j (@{$jobs->{job}}) {
|
||||
|
@ -223,6 +223,11 @@ sub updateJobset {
|
||||
my $jobsetName = trim $c->request->params->{"name"};
|
||||
error($c, "Invalid jobset name: ‘$jobsetName’") if $jobsetName !~ /^$jobsetNameRE$/;
|
||||
|
||||
# When the expression is in a .scm file, assume it's a Guile + Guix
|
||||
# build expression.
|
||||
my $exprType =
|
||||
$c->request->params->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix";
|
||||
|
||||
my ($nixExprPath, $nixExprInput) = nixExprPathFromParams $c;
|
||||
|
||||
$jobset->update(
|
||||
|
@ -146,6 +146,8 @@ sub create_jobset_submit : Chained('project') PathPart('create-jobset/submit') A
|
||||
requireProjectOwner($c, $c->stash->{project});
|
||||
|
||||
my $jobsetName = trim $c->request->params->{name};
|
||||
my $exprType =
|
||||
$c->request->params->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix";
|
||||
|
||||
error($c, "Invalid jobset name: ‘$jobsetName’") if $jobsetName !~ /^$jobsetNameRE$/;
|
||||
|
||||
|
@ -644,8 +644,47 @@ sub fetchInput {
|
||||
}
|
||||
|
||||
|
||||
sub booleanToString {
|
||||
my ($exprType, $value) = @_;
|
||||
my $result;
|
||||
if ($exprType eq "guile") {
|
||||
if ($value eq "true") {
|
||||
$result = "#t";
|
||||
} else {
|
||||
$result = "#f";
|
||||
}
|
||||
$result = $value;
|
||||
} else {
|
||||
$result = $value;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub buildInputToString {
|
||||
my ($exprType, $input) = @_;
|
||||
my $result;
|
||||
if ($exprType eq "guile") {
|
||||
$result = "'((file-name . \"" . ${input}->{storePath} . "\")" .
|
||||
(defined $input->{revision} ? "(revision . \"" . $input->{revision} . "\")" : "") .
|
||||
(defined $input->{revCount} ? "(revision-count . " . $input->{revCount} . ")" : "") .
|
||||
(defined $input->{gitTag} ? "(git-tag . \"" . $input->{gitTag} . "\")" : "") .
|
||||
(defined $input->{shortRev} ? "(short-revision . \"" . $input->{shortRev} . "\")" : "") .
|
||||
(defined $input->{version} ? "(version . \"" . $input->{version} . "\")" : "") .
|
||||
")";
|
||||
} else {
|
||||
$result = "{ outPath = builtins.storePath " . $input->{storePath} . "" .
|
||||
(defined $input->{revision} ? "; rev = \"" . $input->{revision} . "\"" : "") .
|
||||
(defined $input->{revCount} ? "; revCount = " . $input->{revCount} . "" : "") .
|
||||
(defined $input->{gitTag} ? "; gitTag = \"" . $input->{gitTag} . "\"" : "") .
|
||||
(defined $input->{shortRev} ? "; shortRev = \"" . $input->{shortRev} . "\"" : "") .
|
||||
(defined $input->{version} ? "; version = \"" . $input->{version} . "\"" : "") .
|
||||
";}";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub inputsToArgs {
|
||||
my ($inputInfo) = @_;
|
||||
my ($inputInfo, $exprType) = @_;
|
||||
my @res = ();
|
||||
|
||||
foreach my $input (keys %{$inputInfo}) {
|
||||
@ -658,18 +697,10 @@ sub inputsToArgs {
|
||||
push @res, "--argstr", $input, $alt->{value};
|
||||
}
|
||||
when ("boolean") {
|
||||
push @res, "--arg", $input, $alt->{value};
|
||||
push @res, "--arg", $input, booleanToString($exprType, $alt->{value});
|
||||
}
|
||||
when (["path", "build", "git", "hg", "sysbuild"]) {
|
||||
push @res, "--arg", $input, (
|
||||
"{ outPath = builtins.storePath " . $alt->{storePath} . "" .
|
||||
(defined $alt->{revision} ? "; rev = \"" . $alt->{revision} . "\"" : "") .
|
||||
(defined $alt->{revCount} ? "; revCount = " . $alt->{revCount} . "" : "") .
|
||||
(defined $alt->{gitTag} ? "; gitTag = \"" . $alt->{gitTag} . "\"" : "") .
|
||||
(defined $alt->{shortRev} ? "; shortRev = \"" . $alt->{shortRev} . "\"" : "") .
|
||||
(defined $alt->{version} ? "; version = \"" . $alt->{version} . "\"" : "") .
|
||||
";}"
|
||||
);
|
||||
push @res, "--arg", $input, buildInputToString($exprType, $alt);
|
||||
}
|
||||
when (["svn", "svn-checkout", "bzr", "bzr-checkout"]) {
|
||||
push @res, "--arg", $input, (
|
||||
@ -711,7 +742,7 @@ sub captureStdoutStderr {
|
||||
|
||||
|
||||
sub evalJobs {
|
||||
my ($inputInfo, $nixExprInputName, $nixExprPath) = @_;
|
||||
my ($inputInfo, $exprType, $nixExprInputName, $nixExprPath) = @_;
|
||||
|
||||
my $nixExprInput = $inputInfo->{$nixExprInputName}->[0]
|
||||
or die "Cannot find the input containing the job expression.\n";
|
||||
@ -719,8 +750,11 @@ sub evalJobs {
|
||||
if scalar @{$inputInfo->{$nixExprInputName}} != 1;
|
||||
my $nixExprFullPath = $nixExprInput->{storePath} . "/" . $nixExprPath;
|
||||
|
||||
my $evaluator = ($exprType eq "guile") ? "hydra-eval-guile-jobs" : "hydra-eval-jobs";
|
||||
print STDERR "evaluator ${evaluator}\n";
|
||||
|
||||
(my $res, my $jobsXml, my $stderr) = captureStdoutStderr(10800,
|
||||
("hydra-eval-jobs", $nixExprFullPath, "--gc-roots-dir", getGCRootsDir, "-j", 1, inputsToArgs($inputInfo)));
|
||||
($evaluator, $nixExprFullPath, "--gc-roots-dir", getGCRootsDir, "-j", 1, inputsToArgs($inputInfo, $exprType)));
|
||||
die "Cannot evaluate the Nix expression containing the jobs:\n$stderr" unless $res;
|
||||
|
||||
print STDERR "$stderr";
|
||||
|
Reference in New Issue
Block a user