nix-super/src/libexpr/get-drvs.hh

104 lines
2.7 KiB
C++
Raw Normal View History

#pragma once
///@file
#include "eval.hh"
#include "path.hh"
#include <string>
#include <map>
namespace nix {
struct DrvInfo
{
public:
typedef std::map<std::string, std::optional<StorePath>> Outputs;
private:
2013-11-19 15:09:03 +02:00
EvalState * state;
mutable std::string name;
mutable std::string system;
mutable std::optional<std::optional<StorePath>> drvPath;
mutable std::optional<StorePath> outPath;
mutable std::string outputName;
Outputs outputs;
/**
* Set if we get an AssertionError
*/
bool failed = false;
2017-07-17 20:02:56 +03:00
Bindings * attrs = nullptr, * meta = nullptr;
2013-11-19 15:09:03 +02:00
Bindings * getMeta();
bool checkMeta(Value & v);
public:
/**
* path towards the derivation
*/
std::string attrPath;
2017-07-17 20:02:56 +03:00
DrvInfo(EvalState & state) : state(&state) { };
DrvInfo(EvalState & state, std::string attrPath, Bindings * attrs);
DrvInfo(EvalState & state, ref<Store> store, const std::string & drvPathWithOutputs);
2013-11-19 15:09:03 +02:00
std::string queryName() const;
std::string querySystem() const;
std::optional<StorePath> queryDrvPath() const;
StorePath requireDrvPath() const;
StorePath queryOutPath() const;
std::string queryOutputName() const;
/**
* Return the unordered map of output names to (optional) output paths.
* The "outputs to install" are determined by `meta.outputsToInstall`.
*/
Outputs queryOutputs(bool withPaths = true, bool onlyOutputsToInstall = false);
2013-11-19 15:09:03 +02:00
StringSet queryMetaNames();
Value * queryMeta(const std::string & name);
std::string queryMetaString(const std::string & name);
NixInt queryMetaInt(const std::string & name, NixInt def);
NixFloat queryMetaFloat(const std::string & name, NixFloat def);
bool queryMetaBool(const std::string & name, bool def);
void setMeta(const std::string & name, Value * v);
2013-11-19 15:09:03 +02:00
/*
MetaInfo queryMetaInfo(EvalState & state) const;
MetaValue queryMetaInfo(EvalState & state, const string & name) const;
2013-11-19 15:09:03 +02:00
*/
void setName(const std::string & s) { name = s; }
void setDrvPath(StorePath path) { drvPath = {{std::move(path)}}; }
void setOutPath(StorePath path) { outPath = {{std::move(path)}}; }
void setFailed() { failed = true; };
bool hasFailed() { return failed; };
};
#if HAVE_BOEHMGC
2022-05-25 16:49:41 +03:00
typedef std::list<DrvInfo, traceable_allocator<DrvInfo>> DrvInfos;
#else
2022-02-21 17:25:12 +02:00
typedef std::list<DrvInfo> DrvInfos;
#endif
/**
* If value `v` denotes a derivation, return a DrvInfo object
* describing it. Otherwise return nothing.
*/
2019-02-12 14:43:32 +02:00
std::optional<DrvInfo> getDerivation(EvalState & state,
Value & v, bool ignoreAssertionFailures);
void getDerivations(EvalState & state, Value & v, const std::string & pathPrefix,
Bindings & autoArgs, DrvInfos & drvs,
bool ignoreAssertionFailures);
}