![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
#include "nix/store/derivations.hh"#include "nix/util/fun.hh"#include <boost/unordered/concurrent_flat_map_fwd.hpp>Go to the source code of this file.
Classes | |
| struct | nix::derivation::masked::HashInputs |
| struct | nix::derivation::masked::HashInputs::Drvs |
| struct | nix::derivation::masked::MaskedHash |
| struct | nix::derivation::masked::HashFct |
Namespaces | |
| namespace | nix::derivation |
Typedefs | |
| template<typename Out = Output::InputAddressed> | |
| using | nix::derivation::masked::Drv = Derivation<HashInputs, Out> |
| typedef boost::concurrent_flat_map< StorePath, MaskedHash, HashFct > | nix::derivation::masked::Hashes |
Functions | |
| MaskedHash | nix::derivation::masked::hashInput (const StoreDirConfig &store, ReadDerivation &readDerivation, const Full &drv) |
| MaskedHash | nix::derivation::masked::hashInput (Store &store, const Full &drv) |
| template<typename Out> | |
| std::optional< Drv< Output::Deferred > > | nix::derivation::masked::fullyMaskDerivation (const StoreDirConfig &store, ReadDerivation &readDerivation, const Derivation< std::set< SingleDerivedPath >, Out > &drv) |
| template std::optional< Drv< Output::Deferred > > | nix::derivation::masked::fullyMaskDerivation (const StoreDirConfig &store, ReadDerivation &readDerivation, const Full &drv) |
| template std::optional< Drv< Output::Deferred > > | nix::derivation::masked::fullyMaskDerivation (const StoreDirConfig &store, ReadDerivation &readDerivation, const FullDeferred &drv) |
| template std::optional< Drv< Output::Deferred > > | nix::derivation::masked::fullyMaskDerivation (const StoreDirConfig &store, ReadDerivation &readDerivation, const FullInputAddressed &drv) |
| template<typename Out> | |
| std::optional< Drv< Output::Deferred > > | nix::derivation::masked::fullyMaskDerivation (Store &store, const Derivation< std::set< SingleDerivedPath >, Out > &drv) |
| Drv< Output::Deferred > | nix::derivation::masked::fullyMaskDerivation (const StoreDirConfig &store, const Basic &drv) |
| template<typename Out> | |
| Hash | nix::derivation::masked::hashDerivation (const StoreDirConfig &store, const Drv< Out > &drv) |
| template Hash | nix::derivation::masked::hashDerivation (const StoreDirConfig &store, const Drv< Output::Deferred > &drv) |
| template Hash | nix::derivation::masked::hashDerivation (const StoreDirConfig &store, const Drv< Output::InputAddressed > &drv) |
| using nix::derivation::masked::Drv = Derivation<HashInputs, Out> |
An input-masked derivation: its input derivations are named by their masked hash rather than by store path. This is the intermediate form whose ATerm encoding is hashed to compute input addresses.
Out says whether the outputs are masked too:
Neither is a derivation that can be built or written to the store — their inputs name hashes, not paths — but they are exactly what input addresses are computed from, so having them as values rather than only as hashes means the computation can be inspected and compared.
"Output masking" is the traditional name — it is the "masked" store derivation of primops.cc, blanking the output paths in the outputs field and in the env vars named after them alike. "Input masking" is the parallel name for the other half.
| typedef boost::concurrent_flat_map<StorePath, MaskedHash, HashFct> nix::derivation::masked::Hashes |
Memoisation of hashInput.
| Drv< Output::Deferred > nix::derivation::masked::fullyMaskDerivation | ( | const StoreDirConfig & | store, |
| const Basic & | drv ) |
Like the above, but for a resolved (basic) derivation, which has no input derivations to substitute and so cannot fail.
| std::optional< Drv< Output::Deferred > > nix::derivation::masked::fullyMaskDerivation | ( | const StoreDirConfig & | store, |
| ReadDerivation & | readDerivation, | ||
| const Derivation< std::set< SingleDerivedPath >, Out > & | drv ) |
Compute the fully masked derivation, the preimage of a derivation's own input address: input masking and output masking both, i.e. each input derivation replaced by its own masked hash (in place of its store path), and the derivation's own outputs masked — in the outputs field and in the env vars named after them alike.
Returns std::nullopt when an input's output paths are not yet known, and so there is nothing to substitute for it.
| Hash nix::derivation::masked::hashDerivation | ( | const StoreDirConfig & | store, |
| const Drv< Out > & | drv ) |
Hash a masked derivation. For the fully masked form this is what an input address is.
This is total: the masking can fail, hashing it cannot.
The hash algorithm is not a parameter on purpose — "SHA-256 of this ATerm" is part of the on-disk format, not a choice for callers.
| MaskedHash nix::derivation::masked::hashInput | ( | const StoreDirConfig & | store, |
| ReadDerivation & | readDerivation, | ||
| const Full & | drv ) |
Compute the hash with outputs preserved (as InputAddressed). Used for computing a derivation's identity as an input to other derivations.
Returns the appropriate MaskedHash variant:
Returns hashes with the details of fixed-output subderivations expunged.
A fixed-output derivation is a derivation whose outputs have a specified content hash and hash algorithm. (Currently they must have exactly one output (out), which is specified using the outputHash and outputHashAlgo attributes, but the algorithm doesn't assume this.) We don't want changes to such derivations to propagate upwards through the dependency graph, changing output paths everywhere.
For instance, if we change the url in a call to the fetchurl function, we do not want to rebuild everything depending on it—after all, (the hash of) the file being downloaded is unchanged. So the output paths should not change. On the other hand, the derivation paths should change to reflect the new dependency graph.
For fixed-output derivations, this returns a map from the name of each output to its hash, unique up to the output's contents.
For regular derivations, it returns a single hash of the derivation ATerm, after subderivations have been likewise expunged from that derivation.
When the derivation is itself, or (transitively) depends on, a content-addressing derivation without a content address fixed in advance (CAFloating or Impure), MaskedHash::DeferredDrv is returned indicating we cannot yet compute an input address, because we don't yet know what all the inputs are.