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