Add an input type "nix" for passing arbitrary Nix expressions

This commit is contained in:
Eelco Dolstra 2013-09-30 12:03:25 +02:00
parent 4dd1197d89
commit f50477141d
5 changed files with 21 additions and 10 deletions

View file

@ -33,6 +33,7 @@ sub begin :Private {
$c->stash->{inputTypes} = { $c->stash->{inputTypes} = {
'string' => 'String value', 'string' => 'String value',
'boolean' => 'Boolean', 'boolean' => 'Boolean',
'nix' => 'Nix expression',
'build' => 'Build output', 'build' => 'Build output',
'sysbuild' => 'Build output (same system)' 'sysbuild' => 'Build output (same system)'
}; };

View file

@ -157,7 +157,7 @@ sub fetchInput {
elsif ($type eq "sysbuild") { elsif ($type eq "sysbuild") {
@inputs = fetchInputSystemBuild($db, $project, $jobset, $name, $value); @inputs = fetchInputSystemBuild($db, $project, $jobset, $name, $value);
} }
elsif ($type eq "string") { elsif ($type eq "string" || $type eq "nix") {
die unless defined $value; die unless defined $value;
@inputs = { value => $value }; @inputs = { value => $value };
} }
@ -241,6 +241,9 @@ sub inputsToArgs {
when ("boolean") { when ("boolean") {
push @res, "--arg", $input, booleanToString($exprType, $alt->{value}); push @res, "--arg", $input, booleanToString($exprType, $alt->{value});
} }
when ("nix") {
push @res, "--arg", $input, $alt->{value};
}
default { default {
push @res, "--arg", $input, buildInputToString($exprType, $alt); push @res, "--arg", $input, buildInputToString($exprType, $alt);
} }

View file

@ -247,10 +247,12 @@ END;
BLOCK renderShortInputValue; BLOCK renderShortInputValue;
IF input.type == "build" || input.type == "sysbuild" %] IF input.type == "build" || input.type == "sysbuild" %]
<a href="[% c.uri_for('/build' input.dependency.id) %]">[% input.dependency.id %]</a> <a href="[% c.uri_for('/build' input.dependency.id) %]">[% input.dependency.id %]</a>
[% ELSIF input.type == "string" || input.type == "boolean" %] [% ELSIF input.type == "string" %]
<tt>"[% input.value %]"</tt> <tt>"[% HTML.escape(input.value) %]"</tt>
[% ELSIF input.type == "nix" || input.type == "boolean" %]
<tt>[% HTML.escape(input.value) %]</tt>
[% ELSE %] [% ELSE %]
<tt>[% input.uri %][% IF input.revision %] (r[% input.revision %])[% END %]</tt> <tt>[% HTML.escape(input.uri) %][% IF input.revision %] (r[% HTML.escape(input.revision) %])[% END %]</tt>
[% END %] [% END %]
[% END; [% END;
@ -292,13 +294,15 @@ BLOCK renderInputs; %]
<td> <td>
[% IF input.type == "build" || input.type == "sysbuild" %] [% IF input.type == "build" || input.type == "sysbuild" %]
[% INCLUDE renderFullBuildLink build=input.dependency %] [% INCLUDE renderFullBuildLink build=input.dependency %]
[% ELSIF input.type == "string" || input.type == "boolean" %] [% ELSIF input.type == "string" %]
<tt>"[% input.value %]"</tt> <tt>"[% HTML.escape(input.value) %]"</tt>
[% ELSIF input.type == "nix" || input.type == "boolean" %]
<tt>[% HTML.escape(input.value) %]</tt>
[% ELSE %] [% ELSE %]
<tt>[% input.uri %]</tt> <tt>[% HTML.escape(input.uri) %]</tt>
[% END %] [% END %]
</td> </td>
<td>[% IF input.revision %][% input.revision %][% END %]</td> <td>[% IF input.revision %][% HTML.escape(input.revision) %][% END %]</td>
<td><tt>[% input.path %]</tt></td> <td><tt>[% input.path %]</tt></td>
</tr> </tr>
[% END %] [% END %]

View file

@ -141,11 +141,14 @@ fi
args+=(--arg '[% input.name %]' "{ outPath = $inputDir; rev = \"[% input.revision %]\"; }") args+=(--arg '[% input.name %]' "{ outPath = $inputDir; rev = \"[% input.revision %]\"; }")
[% ELSIF input.type == "string" %] [% ELSIF input.type == "string" %]
args+=(--arg '[% input.name %]' '"[% input.value %]"') args+=(--arg '[% input.name %]' '"[% input.value %]"') # FIXME: escape
[% ELSIF input.type == "boolean" %] [% ELSIF input.type == "boolean" %]
args+=(--arg '[% input.name %]' '[% input.value %]') args+=(--arg '[% input.name %]' '[% input.value %]')
[% ELSIF input.type == "nix" %]
args+=(--arg '[% input.name %]' '[% input.value %]') # FIXME: escape
[% ELSE %] [% ELSE %]
echo "$0: input [% input.name %] has unsupported type [% input.type %]" >&2 echo "$0: input [% input.name %] has unsupported type [% input.type %]" >&2
exit 1 exit 1

View file

@ -76,7 +76,7 @@ create table JobsetInputs (
project text not null, project text not null,
jobset text not null, jobset text not null,
name text not null, name text not null,
type text not null, -- "svn", "path", "uri", "string", "boolean" type text not null, -- "svn", "path", "uri", "string", "boolean", "nix"
primary key (project, jobset, name), primary key (project, jobset, name),
foreign key (project, jobset) references Jobsets(project, name) on delete cascade on update cascade foreign key (project, jobset) references Jobsets(project, name) on delete cascade on update cascade
); );