mirror of
https://github.com/NixOS/nix.git
synced 2025-11-19 16:59:35 +01:00
Use std::optional
This commit is contained in:
parent
73176ab160
commit
f731443384
1 changed files with 5 additions and 5 deletions
|
|
@ -8,7 +8,7 @@ using namespace nix;
|
||||||
|
|
||||||
struct CmdBuild : InstallablesCommand, MixDryRun, MixProfile
|
struct CmdBuild : InstallablesCommand, MixDryRun, MixProfile
|
||||||
{
|
{
|
||||||
Path outLink = "result";
|
std::optional<Path> outLink = "result";
|
||||||
BuildMode buildMode = bmNormal;
|
BuildMode buildMode = bmNormal;
|
||||||
|
|
||||||
CmdBuild()
|
CmdBuild()
|
||||||
|
|
@ -25,7 +25,7 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixProfile
|
||||||
addFlag({
|
addFlag({
|
||||||
.longName = "no-link",
|
.longName = "no-link",
|
||||||
.description = "do not create a symlink to the build result",
|
.description = "do not create a symlink to the build result",
|
||||||
.handler = {&outLink, Path("")},
|
.handler = {&outLink, {}},
|
||||||
});
|
});
|
||||||
|
|
||||||
addFlag({
|
addFlag({
|
||||||
|
|
@ -64,19 +64,19 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixProfile
|
||||||
|
|
||||||
if (dryRun) return;
|
if (dryRun) return;
|
||||||
|
|
||||||
if (outLink != "")
|
if (outLink)
|
||||||
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>())
|
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>())
|
||||||
for (size_t i = 0; i < buildables.size(); ++i)
|
for (size_t i = 0; i < buildables.size(); ++i)
|
||||||
std::visit(overloaded {
|
std::visit(overloaded {
|
||||||
[&](BuildableOpaque bo) {
|
[&](BuildableOpaque bo) {
|
||||||
std::string symlink = outLink;
|
std::string symlink = *outLink;
|
||||||
if (i) symlink += fmt("-%d", i);
|
if (i) symlink += fmt("-%d", i);
|
||||||
store2->addPermRoot(bo.path, absPath(symlink));
|
store2->addPermRoot(bo.path, absPath(symlink));
|
||||||
},
|
},
|
||||||
[&](BuildableFromDrv bfd) {
|
[&](BuildableFromDrv bfd) {
|
||||||
auto builtOutputs = store->queryDerivationOutputMap(bfd.drvPath);
|
auto builtOutputs = store->queryDerivationOutputMap(bfd.drvPath);
|
||||||
for (auto & output : builtOutputs) {
|
for (auto & output : builtOutputs) {
|
||||||
std::string symlink = outLink;
|
std::string symlink = *outLink;
|
||||||
if (i) symlink += fmt("-%d", i);
|
if (i) symlink += fmt("-%d", i);
|
||||||
if (output.first != "out") symlink += fmt("-%s", output.first);
|
if (output.first != "out") symlink += fmt("-%s", output.first);
|
||||||
store2->addPermRoot(output.second, absPath(symlink));
|
store2->addPermRoot(output.second, absPath(symlink));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue