Struct tvix_build::proto::BuildRequest
source · pub struct BuildRequest {
pub inputs: Vec<Node>,
pub command_args: Vec<String>,
pub working_dir: String,
pub scratch_paths: Vec<String>,
pub inputs_dir: String,
pub outputs: Vec<String>,
pub environment_vars: Vec<EnvVar>,
pub constraints: Option<BuildConstraints>,
pub additional_files: Vec<AdditionalFile>,
pub refscan_needles: Vec<String>,
}
Expand description
A BuildRequest describes the request of something to be run on the builder. It is distinct from an actual [Build] that has already happened, or might be currently ongoing.
A BuildRequest can be seen as a more normalized version of a Derivation (parsed from A-Term), “writing out” some of the Nix-internal details about how e.g. environment variables in the build are set.
Nix has some impurities when building a Derivation, for example the –cores option ends up as an environment variable in the build, that’s not part of the ATerm.
As of now, we serialize this into the BuildRequest, so builders can stay dumb. This might change in the future.
There’s also a big difference when it comes to how inputs are modelled:
- Nix only uses store path (strings) to describe the inputs. As store paths can be input-addressed, a certain store path can contain different contents (as not all store paths are binary reproducible). This requires that for every input-addressed input, the builder has access to either the input’s deriver (and needs to build it) or else a trusted source for the built input. to upload input-addressed paths, requiring the trusted users concept.
- tvix-build records a list of tvix.castore.v1.Node as inputs. These map from the store path base name to their contents, relieving the builder from having to “trust” any input-addressed paths, contrary to Nix.
While this approach gives a better hermeticity, it has one downside: A BuildRequest can only be sent once the contents of all its inputs are known.
As of now, we’re okay to accept this, but it prevents uploading an entirely-non-IFD subgraph of BuildRequests eagerly.
FUTUREWORK: We might be introducing another way to refer to inputs, to support “send all BuildRequest for a nixpkgs eval to a remote builder and put the laptop to sleep” usecases later.
Fields§
§inputs: Vec<Node>
The list of all root nodes that should be visible in inputs_dir
at the
time of the build.
As all references are content-addressed, no additional signatures are
needed to substitute / make these available in the build environment.
Inputs MUST be sorted by their names.
command_args: Vec<String>
The command (and its args) executed as the build script. In the case of a Nix derivation, this is usually [“/path/to/some-bash/bin/bash”, “-e”, “/path/to/some/builder.sh”].
working_dir: String
The working dir of the command, relative to the build root. “build”, in the case of Nix. This MUST be a clean relative path, without any “.”, “..”, or superfluous slashes.
scratch_paths: Vec<String>
A list of “scratch” paths, relative to the build root. These will be write-able during the build. [build, nix/store] in the case of Nix. These MUST be clean relative paths, without any “.”, “..”, or superfluous slashes, and sorted.
inputs_dir: String
The path where the castore input nodes will be located at, “nix/store” in case of Nix. Builds might also write into here (Nix builds do that). This MUST be a clean relative path, without any “.”, “..”, or superfluous slashes.
outputs: Vec<String>
The list of output paths the build is expected to produce, relative to the root. If the path is not produced, the build is considered to have failed. These MUST be clean relative paths, without any “.”, “..”, or superfluous slashes, and sorted.
environment_vars: Vec<EnvVar>
The list of environment variables and their values that should be set
inside the build environment.
This includes both environment vars set inside the derivation, as well as
more “ephemeral” ones like NIX_BUILD_CORES, controlled by the --cores
CLI option of nix-build
.
For now, we consume this as an option when turning a Derivation into a BuildRequest,
similar to how Nix has a --cores
option.
We don’t want to bleed these very nix-specific sandbox impl details into
(dumber) builders if we don’t have to.
Environment variables are sorted by their keys.
constraints: Option<BuildConstraints>
A set of constraints that need to be satisfied on a build host before a Build can be started.
additional_files: Vec<AdditionalFile>
Additional (small) files and their contents that should be placed into the build environment, but outside inputs_dir. Used for passAsFile and structuredAttrs in Nix.
refscan_needles: Vec<String>
If this is an non-empty list, all paths in outputs
are scanned for these.
For Nix, refscan_needles
would be populated with the nixbase32 hash parts of
every input store path and output store path. The latter is necessary to scan
for references between multi-output derivations.
Trait Implementations§
source§impl Clone for BuildRequest
impl Clone for BuildRequest
source§fn clone(&self) -> BuildRequest
fn clone(&self) -> BuildRequest
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for BuildRequest
impl Debug for BuildRequest
source§impl Default for BuildRequest
impl Default for BuildRequest
source§impl From<BuildRequest> for BuildRequest
impl From<BuildRequest> for BuildRequest
source§fn from(value: BuildRequest) -> Self
fn from(value: BuildRequest) -> Self
source§impl Message for BuildRequest
impl Message for BuildRequest
source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
. Read moresource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
.source§impl PartialEq for BuildRequest
impl PartialEq for BuildRequest
source§impl TryFrom<BuildRequest> for BuildRequest
impl TryFrom<BuildRequest> for BuildRequest
source§type Error = ValidateBuildRequestError
type Error = ValidateBuildRequestError
impl StructuralPartialEq for BuildRequest
Auto Trait Implementations§
impl Freeze for BuildRequest
impl RefUnwindSafe for BuildRequest
impl Send for BuildRequest
impl Sync for BuildRequest
impl Unpin for BuildRequest
impl UnwindSafe for BuildRequest
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request