mirror of
https://github.com/NixOS/nix
synced 2025-06-28 01:11:15 +02:00
Refactor, use MixOutLinkByDefault
This commit is contained in:
parent
7df7bde306
commit
5089f1292d
1 changed files with 3 additions and 24 deletions
|
@ -93,27 +93,9 @@ struct CmdFormatterRun : MixFormatter, MixJSON
|
||||||
|
|
||||||
static auto rFormatterRun = registerCommand2<CmdFormatterRun>({"formatter", "run"});
|
static auto rFormatterRun = registerCommand2<CmdFormatterRun>({"formatter", "run"});
|
||||||
|
|
||||||
struct CmdFormatterBuild : MixFormatter
|
struct CmdFormatterBuild : MixFormatter, MixOutLinkByDefault
|
||||||
{
|
{
|
||||||
Path outLink = "result";
|
CmdFormatterBuild() {}
|
||||||
|
|
||||||
CmdFormatterBuild()
|
|
||||||
{
|
|
||||||
addFlag({
|
|
||||||
.longName = "out-link",
|
|
||||||
.shortName = 'o',
|
|
||||||
.description = "Use *path* as prefix for the symlink to the build result. It defaults to `result`.",
|
|
||||||
.labels = {"path"},
|
|
||||||
.handler = {&outLink},
|
|
||||||
.completer = completePath,
|
|
||||||
});
|
|
||||||
|
|
||||||
addFlag({
|
|
||||||
.longName = "no-link",
|
|
||||||
.description = "Do not create symlink to the build results.",
|
|
||||||
.handler = {&outLink, Path("")},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string description() override
|
std::string description() override
|
||||||
{
|
{
|
||||||
|
@ -142,10 +124,7 @@ struct CmdFormatterBuild : MixFormatter
|
||||||
auto unresolvedApp = installable.toApp(*evalState);
|
auto unresolvedApp = installable.toApp(*evalState);
|
||||||
auto app = unresolvedApp.resolve(evalStore, store);
|
auto app = unresolvedApp.resolve(evalStore, store);
|
||||||
auto buildables = unresolvedApp.build(evalStore, store);
|
auto buildables = unresolvedApp.build(evalStore, store);
|
||||||
|
createOutLinksMaybe(buildables, store);
|
||||||
if (outLink != "")
|
|
||||||
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>())
|
|
||||||
createOutLinks(outLink, toBuiltPaths(buildables), *store2);
|
|
||||||
|
|
||||||
logger->cout("%s", app.program);
|
logger->cout("%s", app.program);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue