20static constexpr Command::Category catHelp = -1;
21static constexpr Command::Category catSecondary = 100;
22static constexpr Command::Category catUtility = 101;
23static constexpr Command::Category catNixInstallation = 102;
25static constexpr auto installablesCategory =
26 "Options that change the interpretation of [installables](@docroot@/command-ref/new-cli/nix.md#installables)";
30 nlohmann::json toJSON()
override;
32 using MultiCommand::MultiCommand;
34 virtual void run()
override;
38#pragma GCC diagnostic ignored "-Woverloaded-virtual"
43struct StoreConfigCommand :
virtual Command
60 std::shared_ptr<StoreConfig> _storeConfig;
66struct StoreCommand :
virtual StoreConfigCommand
83 std::shared_ptr<Store> _store;
90struct CopyCommand :
virtual StoreCommand
92 std::optional<StoreReference> srcUri, dstUri;
104struct EvalCommand :
virtual StoreCommand, MixEvalArgs
106 bool startReplOnEvalErrors =
false;
107 bool ignoreExceptionsDuringTry =
false;
118 std::shared_ptr<Store> evalStore;
120 std::shared_ptr<EvalState> evalState;
127struct MixFlakeOptions :
virtual Args, EvalCommand
147struct SourceExprCommand :
virtual Args, MixFlakeOptions
149 std::optional<std::filesystem::path> file;
150 std::optional<std::string> expr;
158 virtual Strings getDefaultFlakeAttrPaths();
160 virtual Strings getDefaultFlakeAttrPathPrefixes();
180struct MixReadOnlyOption :
virtual Args
191struct RawInstallablesCommand :
virtual Args, SourceExprCommand
193 RawInstallablesCommand();
195 virtual void run(
ref<Store> store, std::vector<std::string> && rawInstallables) = 0;
200 virtual void applyDefaultInstallables(std::vector<std::string> & rawInstallables);
202 bool readFromStdIn =
false;
208 std::vector<std::string> rawInstallables;
219 void run(
ref<Store> store, std::vector<std::string> && rawInstallables)
override;
225struct InstallableCommand :
virtual Args, SourceExprCommand
227 InstallableCommand();
237 std::string _installable{
"."};
240struct MixOperateOnOptions :
virtual Args
244 MixOperateOnOptions();
257 bool recursive =
false;
266 BuiltPathsCommand(
bool recursive =
false);
268 virtual void run(
ref<Store> store, BuiltPaths && allPaths, BuiltPaths && rootPaths) = 0;
272 void applyDefaultInstallables(std::vector<std::string> & rawInstallables)
override;
275struct StorePathsCommand :
public BuiltPathsCommand
277 StorePathsCommand(
bool recursive =
false);
279 virtual void run(
ref<Store> store, StorePaths && storePaths) = 0;
281 void run(
ref<Store> store, BuiltPaths && allPaths, BuiltPaths && rootPaths)
override;
291 void run(
ref<Store> store, StorePaths && storePaths)
override;
297struct RegisterCommand
301 static Commands & commands();
303 RegisterCommand(std::vector<std::string> && name,
fun<
ref<Command>()> command)
305 commands().emplace(name, command);
308 static nix::Commands getCommandsFor(
const std::vector<std::string> & prefix);
318static RegisterCommand registerCommand2(std::vector<std::string> && name)
320 return RegisterCommand(std::move(name), []() {
return make_ref<T>(); });
323struct MixProfile :
virtual StoreCommand
325 std::optional<std::filesystem::path> profile;
334 void updateProfile(
Store & store,
const BuiltPaths & buildables);
337struct MixDefaultProfile : MixProfile
342struct MixEnvironment :
virtual Args
348 bool ignoreEnvironment;
361struct MixNoCheckSigs :
virtual Args
363 CheckSigsFlag checkSigs = CheckSigs;
368 .longName =
"no-check-sigs",
369 .description =
"Do not require that paths are signed by trusted keys.",
370 .handler = {&checkSigs, NoCheckSigs},
375void completeFlakeInputAttrPath(
378 const std::vector<FlakeRef> & flakeRefs,
379 std::string_view prefix);
383void completeFlakeRefWithFragment(
387 Strings attrPathPrefixes,
388 const Strings & defaultFlakeAttrPaths,
389 std::string_view prefix);
391std::string showVersions(
const StringSet & versions);
393void printClosureDiff(
400void createOutLinks(
const std::filesystem::path & outLink,
const BuiltPaths & buildables,
LocalFSStore & store);
403struct MixOutLinkBase :
virtual Args
406 std::optional<std::filesystem::path>
outLink = std::nullopt;
408 MixOutLinkBase(
const std::optional<std::filesystem::path> & defaultOutLink)
420struct MixOutLinkByDefault : MixOutLinkBase,
virtual Args
422 MixOutLinkByDefault()
423 : MixOutLinkBase(
"result")
426 .longName =
"out-link",
428 .description =
"Use *path* as prefix for the symlinks to the build results. It defaults to `result`.",
431 .completer = completePath,
435 .longName =
"no-link",
436 .description =
"Do not create symlinks to the build results.",
437 .handler = {[&] {
outLink = std::nullopt; }},
442struct MixPrintOutPaths :
virtual Args
444 bool printOutputPaths =
false;
449 .longName =
"print-out-paths",
450 .description =
"Print the resulting output paths",
451 .handler = {&printOutputPaths,
true},
455 void printOutPathsMaybe(
const BuiltPaths & paths,
ref<Store> store);
std::function< CompleterFun > CompleterClosure
Definition args.hh:186
Definition store-api.hh:397
OperateOn
Definition installables.hh:44
@ Output
Definition installables.hh:48
Realise
Definition installables.hh:17
@ Derivation
Definition installables.hh:29
std::vector< ref< Installable > > Installables
Definition installables.hh:103
std::vector< FlakeRef > getFlakeRefsForCompletion() override
Definition installables.cc:762
Definition command.hh:216
Definition local-fs-store.hh:91
virtual std::vector< FlakeRef > getFlakeRefsForCompletion()
Definition command.hh:141
void createOutLinksMaybe(const BuiltPaths &paths, ref< Store > &store)
Definition command.cc:446
std::optional< std::filesystem::path > outLink
Definition command.hh:406
virtual void run() override
Definition command.cc:52
Definition position.hh:20
std::vector< FlakeRef > getFlakeRefsForCompletion() override
Definition installables.cc:739
Definition command.hh:298
void completeInstallable(AddCompletions &completions, std::string_view prefix)
Definition installables.cc:246
CompleterClosure getCompleteInstallable()
Definition installables.cc:239
virtual void run(ref< Store >)=0
void run(ref< StoreConfig >) override
Definition command.cc:102
ref< Store > getStore()
Definition command.cc:88
ref< StoreConfig > getStoreConfig()
Definition command.cc:69
void run() override
Definition command.cc:81
virtual void run(ref< StoreConfig >)=0
Definition command.hh:288
std::map< std::string, std::string, std::less<> > StringMap
Definition types.hh:26
std::set< std::string, std::less<> > StringSet
Definition types.hh:45