2023-02-03 21:53:40 +02:00
|
|
|
#pragma once
|
2023-04-01 06:18:41 +03:00
|
|
|
///@file
|
2023-02-03 21:53:40 +02:00
|
|
|
|
|
|
|
#include "installable-value.hh"
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
2023-02-06 06:28:18 +02:00
|
|
|
/**
|
|
|
|
* Extra info about a \ref DerivedPath "derived path" that ultimately
|
|
|
|
* come from a Flake.
|
|
|
|
*
|
|
|
|
* Invariant: every ExtraPathInfo gotten from an InstallableFlake should
|
|
|
|
* be possible to downcast to an ExtraPathInfoFlake.
|
|
|
|
*/
|
|
|
|
struct ExtraPathInfoFlake : ExtraPathInfoValue
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Extra struct to get around C++ designated initializer limitations
|
|
|
|
*/
|
|
|
|
struct Flake {
|
|
|
|
FlakeRef originalRef;
|
|
|
|
FlakeRef resolvedRef;
|
|
|
|
};
|
|
|
|
|
|
|
|
Flake flake;
|
|
|
|
|
|
|
|
ExtraPathInfoFlake(Value && v, Flake && f)
|
|
|
|
: ExtraPathInfoValue(std::move(v)), flake(f)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2023-02-03 21:53:40 +02:00
|
|
|
struct InstallableFlake : InstallableValue
|
|
|
|
{
|
|
|
|
FlakeRef flakeRef;
|
|
|
|
Strings attrPaths;
|
|
|
|
Strings prefixes;
|
|
|
|
ExtendedOutputsSpec extendedOutputsSpec;
|
|
|
|
const flake::LockFlags & lockFlags;
|
|
|
|
mutable std::shared_ptr<flake::LockedFlake> _lockedFlake;
|
|
|
|
|
|
|
|
InstallableFlake(
|
|
|
|
SourceExprCommand * cmd,
|
|
|
|
ref<EvalState> state,
|
|
|
|
FlakeRef && flakeRef,
|
|
|
|
std::string_view fragment,
|
|
|
|
ExtendedOutputsSpec extendedOutputsSpec,
|
|
|
|
Strings attrPaths,
|
|
|
|
Strings prefixes,
|
|
|
|
const flake::LockFlags & lockFlags);
|
|
|
|
|
|
|
|
std::string what() const override { return flakeRef.to_string() + "#" + *attrPaths.begin(); }
|
|
|
|
|
|
|
|
std::vector<std::string> getActualAttrPaths();
|
|
|
|
|
|
|
|
Value * getFlakeOutputs(EvalState & state, const flake::LockedFlake & lockedFlake);
|
|
|
|
|
|
|
|
DerivedPathsWithInfo toDerivedPaths() override;
|
|
|
|
|
|
|
|
std::pair<Value *, PosIdx> toValue(EvalState & state) override;
|
|
|
|
|
2023-02-06 06:28:18 +02:00
|
|
|
/**
|
|
|
|
* Get a cursor to every attrpath in getActualAttrPaths() that
|
|
|
|
* exists. However if none exists, throw an exception.
|
|
|
|
*/
|
2023-02-03 21:53:40 +02:00
|
|
|
std::vector<ref<eval_cache::AttrCursor>>
|
|
|
|
getCursors(EvalState & state) override;
|
|
|
|
|
|
|
|
std::shared_ptr<flake::LockedFlake> getLockedFlake() const;
|
|
|
|
|
2023-05-09 18:50:22 +03:00
|
|
|
FlakeRef nixpkgsFlakeRef() const;
|
2023-02-03 21:53:40 +02:00
|
|
|
};
|
|
|
|
|
2023-05-09 18:50:22 +03:00
|
|
|
/**
|
|
|
|
* Default flake ref for referring to Nixpkgs. For flakes that don't
|
|
|
|
* have their own Nixpkgs input, or other installables.
|
|
|
|
*
|
|
|
|
* It is a layer violation for Nix to know about Nixpkgs; currently just
|
|
|
|
* `nix develop` does. Be wary of using this /
|
|
|
|
* `InstallableFlake::nixpkgsFlakeRef` more places.
|
|
|
|
*/
|
|
|
|
static inline FlakeRef defaultNixpkgsFlakeRef()
|
|
|
|
{
|
|
|
|
return FlakeRef::fromAttrs({{"type","indirect"}, {"id", "nixpkgs"}});
|
|
|
|
}
|
|
|
|
|
2023-02-03 21:53:40 +02:00
|
|
|
ref<eval_cache::EvalCache> openEvalCache(
|
|
|
|
EvalState & state,
|
|
|
|
std::shared_ptr<flake::LockedFlake> lockedFlake);
|
|
|
|
|
|
|
|
}
|