Struct tvix_build::buildservice::build_request::BuildRequest
source · pub struct BuildRequest {
pub inputs: BTreeMap<PathComponent, Node>,
pub command_args: Vec<String>,
pub working_dir: PathBuf,
pub scratch_paths: Vec<PathBuf>,
pub inputs_dir: PathBuf,
pub outputs: Vec<PathBuf>,
pub environment_vars: Vec<EnvVar>,
pub constraints: HashSet<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.
Fields§
§inputs: BTreeMap<PathComponent, 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.
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: PathBuf
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<PathBuf>
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: PathBuf
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<PathBuf>
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: HashSet<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§fn default() -> BuildRequest
fn default() -> 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 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