![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
Classes | |
| struct | Derivation |
| struct | FullInputs |
| struct | Options |
| struct | Output |
| struct | OutputChecks |
| struct | Type |
Concepts | |
| concept | RenderableDerivation |
Typedefs | |
| template<typename Out = Output> | |
| using | Outputs = std::map<std::string, Out> |
| typedef std::map< std::string, std::pair< Output, std::optional< StorePath > > > | OutputsAndOptPaths |
| typedef std::map< StorePath, StringSet > | Inputs |
| using | Basic = Derivation<StorePathSet> |
| Derivation that depends only on other store objects. | |
| using | Full = Derivation<std::set<SingleDerivedPath>> |
| Derivation that depends on the outputs of other derivations in addition. | |
| using | ReadDerivation = fun<Full(const StorePath & drvPath)> |
| using | FullDeferred = Derivation<std::set<SingleDerivedPath>, Output::Deferred> |
| Full, but statically known to have no output paths yet. | |
| using | FullInputAddressed = Derivation<std::set<SingleDerivedPath>, Output::InputAddressed> |
| Full, but statically known to be input-addressed. | |
Enumerations | |
| enum struct | ATermVersion { Traditional , DynamicDerivations } |
Functions | |
| std::optional< Options< StorePath > > | tryResolve (const Options< SingleDerivedPath > &drvOptions, fun< std::optional< StorePath >(ref< const SingleDerivedPath > drvPath, const std::string &outputName)> queryResolutionChain) |
| Full | parse (const StoreDirConfig &store, std::string &&s, std::string_view name, bool supportWindowsStoreDir, const ExperimentalFeatureSettings &xpSettings) |
| template<typename Inputs, typename Out> requires RenderableDerivation<Inputs, Out> | |
| std::string | unparse (const Derivation< Inputs, Out > &drv, const StoreDirConfig &store, bool supportWindowsStoreDir) |
| template std::string | unparse (const masked::Drv< Output::Deferred > &drv, const StoreDirConfig &store, bool) |
| template std::string | unparse (const masked::Drv< Output::InputAddressed > &drv, const StoreDirConfig &store, bool) |
| template<typename Out> | |
| std::string | unparse (const Derivation< std::set< SingleDerivedPath >, Out > &drv, const StoreDirConfig &store, bool supportWindowsStoreDir) |
| template std::string | unparse (const Full &drv, const StoreDirConfig &store, bool) |
| template std::string | unparse (const FullDeferred &drv, const StoreDirConfig &store, bool) |
| template std::string | unparse (const FullInputAddressed &drv, const StoreDirConfig &store, bool) |
| Source & | read (Source &in, const StoreDirConfig &store, Basic &drv, std::string_view name) |
| void | write (Sink &out, const StoreDirConfig &store, const Basic &drv) |
| bool | hasDynamicDrvDep (const FullInputs &inputs) |
| Full | unresolve (const Basic &drv) |
| bool | shouldResolve (const Full &drv) |
| std::optional< Basic > | tryResolve (const Full &drv, Store &store, Store *evalStore) |
| std::optional< Basic > | tryResolve (const Full &drv, Store &store, fun< std::optional< StorePath >(ref< const SingleDerivedPath > drvPath, const std::string &outputName)> queryResolutionChain) |
| template<typename Inputs> | |
| Type | type (const Derivation< Inputs, Output > &drv) |
| template Type | type (const Basic &drv) |
| template Type | type (const Full &drv) |
| template<typename Inputs> | |
| OutputsAndOptPaths | outputsAndOptPaths (const Derivation< Inputs, Output > &drv, const StoreDirConfig &store) |
| template OutputsAndOptPaths | outputsAndOptPaths (const Basic &drv, const StoreDirConfig &store) |
| template OutputsAndOptPaths | outputsAndOptPaths (const Full &drv, const StoreDirConfig &store) |
| bool | hasDynamicDrvDep (const std::set< SingleDerivedPath > &inputs) |
| template<typename Inputs> | |
| void | checkInvariants (const Derivation< Inputs, Output > &drv, const StoreDirConfig &store, auto &&readDerivation, const StorePath &drvPath) |
| template void | checkInvariants (const Basic &drv, const StoreDirConfig &store, std::monostate &&readDerivation, const StorePath &drvPath) |
| template void | checkInvariants (const Full &drv, const StoreDirConfig &store, ReadDerivation &&readDerivation, const StorePath &drvPath) |
| void | checkInvariants (const Basic &drv, const StoreDirConfig &store) |
| void | checkInvariants (const Full &drv, const StoreDirConfig &store, ReadDerivation &readDerivation) |
| void | checkInvariants (const Full &drv, Store &store) |
| ReadDerivation | readInvalid (Store &store) |
| void | fillInOutputPaths (Basic &drv, const StoreDirConfig &store) |
| void | fillInOutputPaths (Full &drv, const StoreDirConfig &store, ReadDerivation &readDerivation) |
| void | fillInOutputPaths (Full &drv, Store &store) |
| std::optional< FullInputAddressed > | fillInOutputPaths (FullDeferred drv, const StoreDirConfig &store, ReadDerivation &readDerivation) |
| Full | parseJsonAndValidate (Store &store, const nlohmann::json &json) |
| template<typename Inputs> | |
| void | checkInvariants (const Derivation< Inputs, Output > &drv, Store &store, const StorePath &drvPath) |
Variables | |
| constexpr bool | defaultSupportWindowsStoreDir |
This represents all the special options on a Derivation.
Currently, these options are parsed from the environment variables with the aid of StructuredAttrs.
The first goal of this data type is to make sure that no other code uses StructuredAttrs to ad-hoc parse some additional options. That ensures this data type is up to date and fully correct.
The second goal of this data type is to allow an alternative to hackily parsing the options from the environment variables. The ATerm format cannot change, but in alternatives to it (like the JSON format), we have the option of instead storing the options separately. That would be nice to separate concerns, and not make any environment variable names magical.
| using nix::derivation::Basic = Derivation<StorePathSet> |
Derivation that depends only on other store objects.
This type is what's used in Store::buildDerivation or for resolved derivations
| using nix::derivation::Full = Derivation<std::set<SingleDerivedPath>> |
Derivation that depends on the outputs of other derivations in addition.
This type is what's constructed by the evaluator and written to the store in ATerm format.
| using nix::derivation::FullDeferred = Derivation<std::set<SingleDerivedPath>, Output::Deferred> |
Full, but statically known to have no output paths yet.
The outputs are Output::Deferred rather than the Output variant, so "we have not computed the output paths" is carried in the type.
| using nix::derivation::FullInputAddressed = Derivation<std::set<SingleDerivedPath>, Output::InputAddressed> |
Full, but statically known to be input-addressed.
The outputs are Output::InputAddressed rather than the Output variant, so "the output paths are computed" is carried in the type.
| typedef std::map<StorePath, StringSet> nix::derivation::Inputs |
For inputs that are sub-derivations, we specify exactly which output IDs we are interested in.
| typedef std::map<std::string, std::pair<Output, std::optional<StorePath> > > nix::derivation::OutputsAndOptPaths |
These are analogues to the previous Outputs data type, but they also contains, for each output, the (optional) store path in which it would be written. To calculate values of these types, see the corresponding functions in Basic.
| using nix::derivation::ReadDerivation = fun<Full(const StorePath & drvPath)> |
How to get a derivation's value from its store path.
Several computations over derivations — filling in output paths, checking invariants, computing masked hash — need to recurse into input derivations, but that is all they need a store for; everything else they touch is StoreDirConfig, for printing paths. Taking just this much lets them be used (and tested) without a real store, and makes it evident from the signature that nothing else is queried.
|
strong |
All ATerm Derivation format versions currently known.
Unknown versions are rejected at the parsing stage.
| Enumerator | |
|---|---|
| Traditional | Older unversioned form |
| DynamicDerivations | Newer versioned form; only this version so far. |
| void nix::derivation::checkInvariants | ( | const Basic & | drv, |
| const StoreDirConfig & | store ) |
Check that the derivation is valid and does not present any illegal states.
This is mainly a matter of checking the outputs, where our C++ representation supports all sorts of combinations we do not yet allow.
This overload does not validate the derivation name or add path context to errors. Use this when you don't have a StorePath or when you want to handle error context yourself.
| store | The store to use for validation |
| void nix::derivation::checkInvariants | ( | const Derivation< Inputs, Output > & | drv, |
| const StoreDirConfig & | store, | ||
| auto && | readDerivation, | ||
| const StorePath & | drvPath ) |
Like the above, but instead of reading input derivations from a store, uses a given ReadDerivation to get them.
| void nix::derivation::checkInvariants | ( | const Derivation< Inputs, Output > & | drv, |
| Store & | store, | ||
| const StorePath & | drvPath ) |
This overload does everything the base checkInvariants does, but also validates that the derivation name matches the path, and improves any error messages that occur using the derivation path.
| store | The store to use for validation |
| drvPath | The path to this derivation |
| void nix::derivation::checkInvariants | ( | const Full & | drv, |
| const StoreDirConfig & | store, | ||
| ReadDerivation & | readDerivation ) |
Like the above, but instead of reading input derivations from a store, uses a given ReadDerivation to get them.
| void nix::derivation::fillInOutputPaths | ( | Basic & | drv, |
| const StoreDirConfig & | store ) |
Fill in output paths as needed.
For input-addressed derivations (ready or deferred), it computes the derivation masked hash and based on the result:
Also for fixed-output content-addressed derivations, likewise updates output paths in env vars.
| store | The store to use for path computation |
| void nix::derivation::fillInOutputPaths | ( | Full & | drv, |
| const StoreDirConfig & | store, | ||
| ReadDerivation & | readDerivation ) |
Like the above, but instead of reading input derivations from a store, uses a given ReadDerivation to get them.
| std::optional< FullInputAddressed > nix::derivation::fillInOutputPaths | ( | FullDeferred | drv, |
| const StoreDirConfig & | store, | ||
| ReadDerivation & | readDerivation ) |
Functional, statically-typed variant of the above, for a derivation all of whose outputs are known to be Deferred.
Rather than mutating in place — which is only possible because Output is a variant able to hold either alternative — this consumes its argument and returns a derivation whose outputs are statically InputAddressed, so the "outputs are filled in now" fact is carried in the type. Everything but the (small) outputs is moved through, so this is no more expensive than the mutating version.
Returns std::nullopt if there is no input address to fill in yet, i.e. when the derivation (transitively) depends on a floating content-addressing derivation. That is the case Deferred exists for, and it is precisely the case this function cannot represent in its return type.
| bool nix::derivation::hasDynamicDrvDep | ( | const FullInputs & | inputs | ) |
Does the derivation have a dependency on the output of a dynamic derivation?
In other words, does it depend on the output of a derivation that is itself an output of a derivation? This corresponds to a dependency that is an inductive derived path with more than one layer of DerivedPath::Built.
| bool nix::derivation::hasDynamicDrvDep | ( | const std::set< SingleDerivedPath > & | inputs | ) |
Does the derivation have a dependency on the output of a dynamic derivation?
In other words, does it depend on the output of a derivation that is itself an output of a derivation? This corresponds to a dependency that is an inductive derived path with more than one layer of DerivedPath::Built.
| OutputsAndOptPaths nix::derivation::outputsAndOptPaths | ( | const Derivation< Inputs, Output > & | drv, |
| const StoreDirConfig & | store ) |
Calculates the maps that contains all the Outputs, but augmented with knowledge of the Store paths they would be written into.
| Full nix::derivation::parse | ( | const StoreDirConfig & | store, |
| std::string && | s, | ||
| std::string_view | name, | ||
| bool | supportWindowsStoreDir = defaultSupportWindowsStoreDir, | ||
| const ExperimentalFeatureSettings & | xpSettings = experimentalFeatureSettings ) |
Read a derivation from a file.
Parse a derivation from JSON, and also perform various conveniences such as:
In the future it might also do things like:
| store | The store to use for path computation and validation |
| json | The JSON representation of the derivation |
| Error | if parsing fails, output paths can't be computed, or validation fails |
| ReadDerivation nix::derivation::readInvalid | ( | Store & | store | ) |
Store::readInvalidDerivation as a ReadDerivation, for callers that do have a whole store to hand.
| bool nix::derivation::shouldResolve | ( | const Full & | drv | ) |
Determine whether this derivation should be resolved before building.
Resolution is needed when:
| std::optional< Basic > nix::derivation::tryResolve | ( | const Full & | drv, |
| Store & | store, | ||
| fun< std::optional< StorePath >(ref< const SingleDerivedPath > drvPath, const std::string &outputName)> | queryResolutionChain ) |
Like the above, but instead of querying the Nix database for realisations, uses a given mapping from input derivation paths + output names to actual output store paths.
| std::optional< Basic > nix::derivation::tryResolve | ( | const Full & | drv, |
| Store & | store, | ||
| Store * | evalStore = nullptr ) |
Return the underlying basic derivation but with these changes:
| std::optional< Options< StorePath > > nix::derivation::tryResolve | ( | const Options< SingleDerivedPath > & | drvOptions, |
| fun< std::optional< StorePath >(ref< const SingleDerivedPath > drvPath, const std::string &outputName)> | queryResolutionChain ) |
This is the counterpart of Derivation::tryResolve. In particular, it takes the same sort of callback, which is used to resolve non-constant deriving paths.
We need this function when resolving a derivation, and we will use this as part of that if/when Derivation includes DerivationOptions
| Type nix::derivation::type | ( | const Derivation< Inputs, Output > & | drv | ) |
Return true iff this is a fixed-output derivation.
| std::string nix::derivation::unparse | ( | const Derivation< Inputs, Out > & | drv, |
| const StoreDirConfig & | store, | ||
| bool | supportWindowsStoreDir ) |
This one, unlike the public one, is polymorphic on the output parameter to support the masked hash intermediate form.
Print a derivation in one of the intermediate forms.
The masked::HashInputs cases are not round-trippable: parse cannot read them back, as their input derivations are named by hash rather than by store path.
| std::string nix::derivation::unparse | ( | const Derivation< std::set< SingleDerivedPath >, Out > & | drv, |
| const StoreDirConfig & | store, | ||
| bool | supportWindowsStoreDir = defaultSupportWindowsStoreDir ) |
Print a derivation.
|
inlineconstexpr |
Whether the store directory may contain characters that the ATerm format escapes — in practice the \\endiskip of a Windows store directory such as C:\ProgramData\nix\store.
We could always enable it, as escape sequences should only be allowed to be used when needed, but out of an abundance of caution we make it a flag instead.