de-inheritance CmdEval for InstallableValueCommand

Change-Id: I08b1702310e863d15de26dc838eb0bcb62417c10
This commit is contained in:
Qyriad 2024-06-17 14:33:28 -06:00
parent 8ba1939540
commit 1e5f134560

View file

@ -1,4 +1,4 @@
#include "command-installable-value.hh" #include "command.hh"
#include "common-args.hh" #include "common-args.hh"
#include "print-options.hh" #include "print-options.hh"
#include "shared.hh" #include "shared.hh"
@ -12,13 +12,13 @@
using namespace nix; using namespace nix;
struct CmdEval : MixJSON, InstallableValueCommand, MixReadOnlyOption struct CmdEval : MixJSON, InstallableCommand, MixReadOnlyOption
{ {
bool raw = false; bool raw = false;
std::optional<std::string> apply; std::optional<std::string> apply;
std::optional<Path> writeTo; std::optional<Path> writeTo;
CmdEval() : InstallableValueCommand() CmdEval() : InstallableCommand()
{ {
addFlag({ addFlag({
.longName = "raw", .longName = "raw",
@ -55,14 +55,16 @@ struct CmdEval : MixJSON, InstallableValueCommand, MixReadOnlyOption
Category category() override { return catSecondary; } Category category() override { return catSecondary; }
void run(ref<Store> store, ref<InstallableValue> installable) override void run(ref<Store> store, ref<Installable> installable) override
{ {
if (raw && json) if (raw && json)
throw UsageError("--raw and --json are mutually exclusive"); throw UsageError("--raw and --json are mutually exclusive");
auto const installableValue = InstallableValue::require(installable);
auto state = getEvalState(); auto state = getEvalState();
auto [v, pos] = installable->toValue(*state); auto [v, pos] = installableValue->toValue(*state);
NixStringContext context; NixStringContext context;
if (apply) { if (apply) {