Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::DesugaredEnv Struct Reference

#include <derivation-env-desugar.hh>

Classes

struct  EnvEntry

Public Member Functions

std::string & atFileEnvPair (std::string_view name, std::string fileName)

Static Public Member Functions

static DesugaredEnv create (Store &store, const BasicDerivation &drv, const derivation::Options< StorePath > &drvOptions, const StorePathSet &inputPaths)

Public Attributes

std::map< std::string, EnvEntry, std::less<> > variables
StringMap extraFiles

Detailed Description

Derivations claim to "just" specify their environment variables, but actually do a number of different features, such as "structured attrs", "pass as file", and "export references graph", things are more complicated then they appear.

The good news is that we can simplify all that to the following view, where environment variables and extra files are specified exactly, with no special cases.

Because we have DesugaredEnv, DerivationBuilder doesn't need to know about any of those above features, and their special case.

Member Function Documentation

◆ atFileEnvPair()

std::string & nix::DesugaredEnv::atFileEnvPair ( std::string_view name,
std::string fileName )

A common case is to define an environment variable that points to a file, which contains some contents.

In base:

export VAR=FILE_NAME
echo CONTENTS >FILE_NAME

This function assists in doing both parts, so the file name is kept in sync.

◆ create()

DesugaredEnv nix::DesugaredEnv::create ( Store & store,
const BasicDerivation & drv,
const derivation::Options< StorePath > & drvOptions,
const StorePathSet & inputPaths )
static

Given a (resolved) derivation, its options, and the closure of its inputs (which we can get since the derivation is resolved), desugar the environment to create a DesguaredEnv.

Todo
drvOptions will go away as a separate argument when it is just part of Derivation.

Member Data Documentation

◆ extraFiles

StringMap nix::DesugaredEnv::extraFiles

Extra file to be placed in the build directory.

Note
EnvEntry::prependBuildDirectory can be used to refer to those files without knowing what the build directory is.

◆ variables

std::map<std::string, EnvEntry, std::less<> > nix::DesugaredEnv::variables

The final environment variables to set.


The documentation for this struct was generated from the following files: