1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 22:01:15 +02:00

Add EvalState::coerceToStorePath() helper

This is useful whenever we want to evaluate something to a store path
(e.g. in get-drvs.cc).

Extracted from the lazy-trees branch (where we can require that a
store path must come from a store source tree accessor).
This commit is contained in:
Eelco Dolstra 2022-03-02 10:57:19 +01:00
parent 3e3d0711d4
commit b55d79728c
13 changed files with 123 additions and 101 deletions

View file

@ -1,6 +1,7 @@
#pragma once
#include "eval.hh"
#include "path.hh"
#include <string>
#include <map>
@ -12,15 +13,15 @@ namespace nix {
struct DrvInfo
{
public:
typedef std::map<std::string, Path> Outputs;
typedef std::map<std::string, StorePath> Outputs;
private:
EvalState * state;
mutable std::string name;
mutable std::string system;
mutable std::string drvPath;
mutable std::optional<std::string> outPath;
mutable std::optional<std::optional<StorePath>> drvPath;
mutable std::optional<StorePath> outPath;
mutable std::string outputName;
Outputs outputs;
@ -41,8 +42,9 @@ public:
std::string queryName() const;
std::string querySystem() const;
std::string queryDrvPath() const;
std::string queryOutPath() const;
std::optional<StorePath> queryDrvPath() const;
StorePath requireDrvPath() const;
StorePath queryOutPath() const;
std::string queryOutputName() const;
/** Return the list of outputs. The "outputs to install" are determined by `meta.outputsToInstall`. */
Outputs queryOutputs(bool onlyOutputsToInstall = false);
@ -61,8 +63,8 @@ public:
*/
void setName(const std::string & s) { name = s; }
void setDrvPath(const std::string & s) { drvPath = s; }
void setOutPath(const std::string & s) { outPath = 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; };