Function tvix_glue::builtins::derivation::handle_fixed_output

source ·
fn handle_fixed_output(
    drv: &mut Derivation,
    hash_str: Option<String>,
    hash_algo_str: Option<String>,
    hash_mode_str: Option<String>,
) -> Result<Option<WarningKind>, ErrorKind>
Expand description

Populate the output configuration of a derivation based on the parameters passed to the call, configuring a fixed-output derivation output if necessary.

This function handles all possible combinations of the parameters, including invalid ones.

Due to the support for SRI hashes, and how these are passed along to builtins.derivation, outputHash and outputHashAlgo can have values which need to be further modified before constructing the Derivation struct.

If outputHashAlgo is an SRI hash, outputHashAlgo must either be an empty string, or the hash algorithm as specified in the (single) SRI (entry). SRI strings with multiple hash algorithms are not supported.

In case an SRI string was used, the (single) fixed output is populated with the hash algo name, and the hash digest is populated with the (lowercase) hex encoding of the digest.

These values are only rewritten for the outputs, not what’s passed to env.

The return value may optionally contain a warning.