mirror of
https://github.com/NixOS/nix
synced 2025-06-26 15:51:15 +02:00
Make --read-only
a separate mixin
It is independent of SourceExprCommand, which is about parsing installables, except for the fact that parsing installables is one of the many things influenced by read-only mode.
This commit is contained in:
parent
924ef6761b
commit
0258ac9c2a
3 changed files with 23 additions and 22 deletions
|
@ -147,7 +147,7 @@ void MixFlakeOptions::completionHook()
|
|||
completeFlakeInput(*prefix);
|
||||
}
|
||||
|
||||
SourceExprCommand::SourceExprCommand(bool supportReadOnlyMode)
|
||||
SourceExprCommand::SourceExprCommand()
|
||||
{
|
||||
addFlag({
|
||||
.longName = "file",
|
||||
|
@ -169,17 +169,18 @@ SourceExprCommand::SourceExprCommand(bool supportReadOnlyMode)
|
|||
.labels = {"expr"},
|
||||
.handler = {&expr}
|
||||
});
|
||||
}
|
||||
|
||||
if (supportReadOnlyMode) {
|
||||
addFlag({
|
||||
.longName = "read-only",
|
||||
.description =
|
||||
"Do not instantiate each evaluated derivation. "
|
||||
"This improves performance, but can cause errors when accessing "
|
||||
"store paths of derivations during evaluation.",
|
||||
.handler = {&readOnlyMode, true},
|
||||
});
|
||||
}
|
||||
MixReadOnlyOption::MixReadOnlyOption()
|
||||
{
|
||||
addFlag({
|
||||
.longName = "read-only",
|
||||
.description =
|
||||
"Do not instantiate each evaluated derivation. "
|
||||
"This improves performance, but can cause errors when accessing "
|
||||
"store paths of derivations during evaluation.",
|
||||
.handler = {&settings.readOnlyMode, true},
|
||||
});
|
||||
}
|
||||
|
||||
Strings SourceExprCommand::getDefaultFlakeAttrPaths()
|
||||
|
@ -426,10 +427,6 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
|
|||
{
|
||||
std::vector<std::shared_ptr<Installable>> result;
|
||||
|
||||
if (readOnlyMode) {
|
||||
settings.readOnlyMode = true;
|
||||
}
|
||||
|
||||
if (file || expr) {
|
||||
if (file && expr)
|
||||
throw UsageError("'--file' and '--expr' are exclusive");
|
||||
|
@ -724,8 +721,8 @@ std::vector<std::string> InstallablesCommand::getFlakesForCompletion()
|
|||
return _installables;
|
||||
}
|
||||
|
||||
InstallableCommand::InstallableCommand(bool supportReadOnlyMode)
|
||||
: SourceExprCommand(supportReadOnlyMode)
|
||||
InstallableCommand::InstallableCommand()
|
||||
: SourceExprCommand()
|
||||
{
|
||||
expectArgs({
|
||||
.label = "installable",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue