Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
get-drvs.hh
Go to the documentation of this file.
1#pragma once
3
4#include "nix/expr/eval.hh"
5#include "nix/store/path.hh"
6
7#include <string>
8#include <map>
9
10namespace nix {
11
15struct PackageInfo
16{
17public:
18 typedef std::map<std::string, std::optional<StorePath>, std::less<>> Outputs;
19
20private:
21 EvalState * state;
22
23 mutable std::string name;
24 mutable std::string system;
25 mutable std::optional<std::optional<StorePath>> drvPath;
26 mutable std::optional<StorePath> outPath;
27 mutable std::string outputName;
28 Outputs outputs;
29
33 bool failed = false;
34
35 const Bindings *attrs = nullptr, *meta = nullptr;
36
37 const Bindings * getMeta();
38
39 bool checkMeta(Value & v);
40
41public:
45 std::string attrPath;
46
47 PackageInfo(EvalState & state)
48 : state(&state) {};
49 PackageInfo(EvalState & state, std::string attrPath, const Bindings * attrs);
50 PackageInfo(EvalState & state, ref<Store> store, const std::string & drvPathWithOutputs);
51
52 std::string queryName() const;
53 std::string querySystem() const;
54 std::optional<StorePath> queryDrvPath() const;
55 StorePath requireDrvPath() const;
56 StorePath queryOutPath() const;
57 std::string queryOutputName() const;
62 Outputs queryOutputs(bool withPaths = true, bool onlyOutputsToInstall = false);
63
64 StringSet queryMetaNames();
65 Value * queryMeta(const std::string & name);
66 std::string queryMetaString(const std::string & name);
67 NixInt queryMetaInt(const std::string & name, NixInt def);
68 NixFloat queryMetaFloat(const std::string & name, NixFloat def);
69 bool queryMetaBool(const std::string & name, bool def);
70 void setMeta(const std::string & name, Value * v);
71
72 /*
73 MetaInfo queryMetaInfo(EvalState & state) const;
74 MetaValue queryMetaInfo(EvalState & state, const string & name) const;
75 */
76
77 void setName(const std::string & s)
78 {
79 name = s;
80 }
81
82 void setDrvPath(StorePath path)
83 {
84 drvPath = {{std::move(path)}};
85 }
86
87 void setOutPath(StorePath path)
88 {
89 outPath = {{std::move(path)}};
90 }
91
92 void setFailed()
93 {
94 failed = true;
95 };
96
97 bool hasFailed()
98 {
99 return failed;
100 };
101};
102
103typedef std::list<PackageInfo, traceable_allocator<PackageInfo>> PackageInfos;
104
109std::optional<PackageInfo> getDerivation(EvalState & state, Value & v, bool ignoreAssertionFailures);
110
111void getDerivations(
112 EvalState & state,
113 Value & v,
114 const std::string & pathPrefix,
115 const Bindings & autoArgs,
116 PackageInfos & drvs,
117 bool ignoreAssertionFailures);
118
119} // namespace nix
Definition attr-set.hh:67
Definition eval.hh:420
Definition path.hh:33
Definition ref.hh:58
Definition get-drvs.hh:16
std::string attrPath
Definition get-drvs.hh:45
Outputs queryOutputs(bool withPaths=true, bool onlyOutputsToInstall=false)
Definition get-drvs.cc:107
Definition value.hh:1166
std::set< std::string, std::less<> > StringSet
Definition types.hh:45