2012-07-18 14:59:03 -04:00
|
|
|
#pragma once
|
2006-02-08 13:21:16 +00:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2020-05-19 15:54:39 +01:00
|
|
|
|
2010-10-04 17:55:38 +00:00
|
|
|
#include "eval.hh"
|
2006-02-08 13:21:16 +00:00
|
|
|
|
2006-09-04 21:06:23 +00:00
|
|
|
namespace nix {
|
|
|
|
|
2006-02-08 13:21:16 +00:00
|
|
|
struct DrvInfo {
|
2020-05-17 16:31:57 +01:00
|
|
|
public:
|
2012-11-28 13:49:44 +01:00
|
|
|
typedef std::map<string, Path> Outputs;
|
2006-09-04 21:06:23 +00:00
|
|
|
|
2006-02-08 13:21:16 +00:00
|
|
|
private:
|
2013-11-19 14:09:03 +01:00
|
|
|
EvalState* state;
|
|
|
|
|
2020-05-21 05:43:22 +01:00
|
|
|
mutable std::string name;
|
|
|
|
mutable std::string system;
|
|
|
|
mutable std::string drvPath;
|
|
|
|
mutable std::string outPath;
|
|
|
|
mutable std::string outputName;
|
2012-11-28 13:49:44 +01:00
|
|
|
Outputs outputs;
|
2010-04-19 12:10:04 +00:00
|
|
|
|
2017-07-17 19:02:56 +02:00
|
|
|
bool failed = false; // set if we get an AssertionError
|
2012-11-28 13:49:44 +01:00
|
|
|
|
2017-07-17 19:02:56 +02:00
|
|
|
Bindings *attrs = nullptr, *meta = nullptr;
|
2013-11-19 14:09:03 +01:00
|
|
|
|
|
|
|
Bindings* getMeta();
|
|
|
|
|
2013-11-19 14:29:39 +01:00
|
|
|
bool checkMeta(Value& v);
|
|
|
|
|
2006-02-08 13:21:16 +00:00
|
|
|
public:
|
2020-05-21 05:43:22 +01:00
|
|
|
std::string attrPath; /* path towards the derivation */
|
2006-02-08 13:21:16 +00:00
|
|
|
|
2017-07-17 19:02:56 +02:00
|
|
|
DrvInfo(EvalState& state) : state(&state){};
|
2020-05-21 05:43:22 +01:00
|
|
|
DrvInfo(EvalState& state, std::string attrPath, Bindings* attrs);
|
2020-05-20 22:58:43 +01:00
|
|
|
DrvInfo(EvalState& state, const ref<Store>& store,
|
2017-11-24 18:07:29 +01:00
|
|
|
const std::string& drvPathWithOutputs);
|
2013-11-19 14:09:03 +01:00
|
|
|
|
2020-05-21 05:43:22 +01:00
|
|
|
std::string queryName() const;
|
|
|
|
std::string querySystem() const;
|
|
|
|
std::string queryDrvPath() const;
|
|
|
|
std::string queryOutPath() const;
|
|
|
|
std::string queryOutputName() const;
|
2018-10-31 20:50:18 +01:00
|
|
|
/** Return the list of outputs. The "outputs to install" are determined by
|
|
|
|
* `meta.outputsToInstall`. */
|
2016-02-23 14:19:14 +01:00
|
|
|
Outputs queryOutputs(bool onlyOutputsToInstall = false);
|
2006-02-08 13:21:16 +00:00
|
|
|
|
2013-11-19 14:09:03 +01:00
|
|
|
StringSet queryMetaNames();
|
2020-05-21 05:43:22 +01:00
|
|
|
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);
|
2010-04-19 12:10:04 +00:00
|
|
|
|
2013-11-19 14:09:03 +01:00
|
|
|
/*
|
2006-03-10 16:20:42 +00:00
|
|
|
MetaInfo queryMetaInfo(EvalState & state) const;
|
2020-05-21 05:43:22 +01:00
|
|
|
MetaValue queryMetaInfo(EvalState & state, const std::string & name) const;
|
2013-11-19 14:09:03 +01:00
|
|
|
*/
|
2006-02-08 13:21:16 +00:00
|
|
|
|
2020-05-21 05:43:22 +01:00
|
|
|
void setName(const std::string& s) { name = s; }
|
|
|
|
void setDrvPath(const std::string& s) { drvPath = s; }
|
|
|
|
void setOutPath(const std::string& s) { outPath = s; }
|
2007-02-02 01:52:42 +00:00
|
|
|
|
2012-07-11 10:14:06 -04:00
|
|
|
void setFailed() { failed = true; };
|
|
|
|
bool hasFailed() { return failed; };
|
2006-02-08 13:21:16 +00:00
|
|
|
};
|
|
|
|
|
2010-11-25 13:47:34 +00:00
|
|
|
#if HAVE_BOEHMGC
|
|
|
|
typedef list<DrvInfo, traceable_allocator<DrvInfo> > DrvInfos;
|
|
|
|
#else
|
2006-02-08 13:21:16 +00:00
|
|
|
typedef list<DrvInfo> DrvInfos;
|
2010-11-25 13:47:34 +00:00
|
|
|
#endif
|
2006-02-08 13:21:16 +00:00
|
|
|
|
2017-07-20 13:32:01 +02:00
|
|
|
/* If value `v' denotes a derivation, return a DrvInfo object
|
|
|
|
describing it. Otherwise return nothing. */
|
2019-02-12 13:43:32 +01:00
|
|
|
std::optional<DrvInfo> getDerivation(EvalState& state, Value& v,
|
2012-10-04 15:22:25 -04:00
|
|
|
bool ignoreAssertionFailures);
|
2006-02-08 13:21:16 +00:00
|
|
|
|
2020-05-21 05:43:22 +01:00
|
|
|
void getDerivations(EvalState& state, Value& v, const std::string& pathPrefix,
|
2012-10-04 15:22:25 -04:00
|
|
|
Bindings& autoArgs, DrvInfos& drvs,
|
2017-07-20 13:32:01 +02:00
|
|
|
bool ignoreAssertionFailures);
|
2012-11-28 13:49:44 +01:00
|
|
|
|
2006-09-04 21:06:23 +00:00
|
|
|
} // namespace nix
|