1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 16:51:15 +02:00

Move value-only methods to InstallableValue

These methods would previously fail on the other `Installable`s, so
moving them to this class is more correct as to where they actually
work.

Additionally, a `InstallableValueCommand` is created to make it easier
(or rather no worse than before) to write commands that just work on
`InstallableValue`s.

Besides being a cleanup to avoid failing default methods, this gets us
closer to https://github.com/NixOS/rfcs/pull/134.
This commit is contained in:
John Ericson 2023-02-05 12:16:17 -05:00
parent acd707acca
commit c998e0172f
14 changed files with 127 additions and 71 deletions

View file

@ -1,4 +1,4 @@
#include "command.hh"
#include "command-installable-value.hh"
#include "common-args.hh"
#include "shared.hh"
#include "store-api.hh"
@ -11,13 +11,13 @@
using namespace nix;
struct CmdEval : MixJSON, InstallableCommand, MixReadOnlyOption
struct CmdEval : MixJSON, InstallableValueCommand, MixReadOnlyOption
{
bool raw = false;
std::optional<std::string> apply;
std::optional<Path> writeTo;
CmdEval() : InstallableCommand()
CmdEval() : InstallableValueCommand()
{
addFlag({
.longName = "raw",
@ -54,7 +54,7 @@ struct CmdEval : MixJSON, InstallableCommand, MixReadOnlyOption
Category category() override { return catSecondary; }
void run(ref<Store> store, ref<Installable> installable) override
void run(ref<Store> store, ref<InstallableValue> installable) override
{
if (raw && json)
throw UsageError("--raw and --json are mutually exclusive");