Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
derivations.hh File Reference
#include "lix/libstore/path.hh"
#include "lix/libutil/result.hh"
#include "lix/libutil/types.hh"
#include "lix/libutil/hash.hh"
#include "lix/libstore/content-address.hh"
#include "lix/libutil/repair-flag.hh"
#include "lix/libstore/derived-path-map.hh"
#include "lix/libutil/sync.hh"
#include "lix/libutil/comparator.hh"
#include "lix/libutil/variant-wrapper.hh"
#include <kj/async.h>
#include <map>
#include <variant>

Go to the source code of this file.

Classes

struct  nix::DerivationOutput
struct  nix::DerivationOutput::InputAddressed
struct  nix::DerivationOutput::CAFixed
struct  nix::DerivationOutput::CAFloating
struct  nix::DerivationOutput::Deferred
struct  nix::DerivationOutput::Impure
struct  nix::DerivationType
struct  nix::DerivationType::InputAddressed
struct  nix::DerivationType::ContentAddressed
struct  nix::DerivationType::Impure
struct  nix::BasicDerivation
struct  nix::Derivation
struct  nix::DrvHash

Typedefs

typedef std::map< std::string, DerivationOutputnix::DerivationOutputs
typedef std::map< std::string, std::pair< DerivationOutput, std::optional< StorePath > > > nix::DerivationOutputsAndOptPaths
typedef std::map< StorePath, StringSet > nix::DerivationInputs
typedef std::map< StorePath, DrvHashnix::DrvHashes

Functions

kj::Promise< Result< StorePath > > nix::writeDerivation (Store &store, const Derivation &drv, RepairFlag repair, bool readOnly)
Derivation nix::parseDerivation (const Store &store, std::string &&s, std::string_view name, const ExperimentalFeatureSettings &xpSettings)
bool nix::isDerivation (std::string_view fileName)
std::string nix::outputPathName (std::string_view drvName, OutputNameView outputName)
void nix::operator|= (DrvHash::Kind &self, const DrvHash::Kind &other) noexcept
kj::Promise< Result< DrvHash > > nix::hashDerivationModulo (Store &store, const Derivation &drv, bool maskOutputs)
kj::Promise< Result< std::map< std::string, Hash > > > nix::staticOutputHashes (Store &store, const Derivation &drv)
Sourcenix::readDerivation (Source &in, const Store &store, BasicDerivation &drv, std::string_view name)
void nix::writeDerivation (Sink &out, const Store &store, const BasicDerivation &drv)
std::string nix::hashPlaceholder (const OutputNameView outputName)

Typedef Documentation

◆ DerivationInputs

typedef std::map<StorePath, StringSet> nix::DerivationInputs

For inputs that are sub-derivations, we specify exactly which output IDs we are interested in.

◆ DerivationOutputsAndOptPaths

typedef std::map<std::string, std::pair<DerivationOutput, std::optional<StorePath> > > nix::DerivationOutputsAndOptPaths

These are analogues to the previous DerivationOutputs 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 BasicDerivation.

◆ DrvHashes

typedef std::map<StorePath, DrvHash> nix::DrvHashes

Memoisation of hashDerivationModulo().

Function Documentation

◆ hashDerivationModulo()

kj::Promise< Result< DrvHash > > nix::hashDerivationModulo ( Store & store,
const Derivation & drv,
bool maskOutputs )

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.

◆ hashPlaceholder()

std::string nix::hashPlaceholder ( const OutputNameView outputName)

This creates an opaque and almost certainly unique string deterministically from the output name.

It is used as a placeholder to allow derivations to refer to their own outputs without needing to use the hash of a derivation in itself, making the hash near-impossible to calculate.

◆ isDerivation()

bool nix::isDerivation ( std::string_view fileName)
Todo
Remove.

Use Path::isDerivation instead.

◆ outputPathName()

std::string nix::outputPathName ( std::string_view drvName,
OutputNameView outputName )

Calculate the name that will be used for the store path for this output.

This is usually <drv-name>-<output-name>, but is just <drv-name> when the output name is "out".

◆ parseDerivation()

Derivation nix::parseDerivation ( const Store & store,
std::string && s,
std::string_view name,
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings )

Read a derivation from a file.

◆ staticOutputHashes()

kj::Promise< Result< std::map< std::string, Hash > > > nix::staticOutputHashes ( Store & store,
const Derivation & drv )

Return a map associating each output to a hash that uniquely identifies its derivation (modulo the self-references).

Todo
What is the Hash in this map?

◆ writeDerivation()

kj::Promise< Result< StorePath > > nix::writeDerivation ( Store & store,
const Derivation & drv,
RepairFlag repair = NoRepair,
bool readOnly = false )

Write a derivation to the Nix store, and return its path.