forked from lix-project/lix
nix build: Add --out-link and --no-link options
This commit is contained in:
parent
df4342bc17
commit
dff440aab3
|
@ -80,6 +80,19 @@ public:
|
||||||
FlagMaker & arity(size_t arity) { flag->arity = arity; return *this; };
|
FlagMaker & arity(size_t arity) { flag->arity = arity; return *this; };
|
||||||
FlagMaker & handler(std::function<void(Strings)> handler) { flag->handler = handler; return *this; };
|
FlagMaker & handler(std::function<void(Strings)> handler) { flag->handler = handler; return *this; };
|
||||||
FlagMaker & category(const std::string & s) { flag->category = s; return *this; };
|
FlagMaker & category(const std::string & s) { flag->category = s; return *this; };
|
||||||
|
|
||||||
|
FlagMaker & dest(std::string * dest) {
|
||||||
|
assert(flag->arity == 1);
|
||||||
|
flag->handler = [=](Strings ss) { *dest = ss.front(); };
|
||||||
|
return *this;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
FlagMaker & set(T * dest, const T & val) {
|
||||||
|
assert(flag->arity == 0);
|
||||||
|
flag->handler = [=](Strings ss) { *dest = val; };
|
||||||
|
return *this;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
FlagMaker mkFlag();
|
FlagMaker mkFlag();
|
||||||
|
|
|
@ -7,8 +7,22 @@ using namespace nix;
|
||||||
|
|
||||||
struct CmdBuild : MixDryRun, InstallablesCommand
|
struct CmdBuild : MixDryRun, InstallablesCommand
|
||||||
{
|
{
|
||||||
|
Path outLink = "result";
|
||||||
|
|
||||||
CmdBuild()
|
CmdBuild()
|
||||||
{
|
{
|
||||||
|
mkFlag()
|
||||||
|
.longName("out-link")
|
||||||
|
.shortName('o')
|
||||||
|
.description("path of the symlink to the build result")
|
||||||
|
.arity(1)
|
||||||
|
.labels({"path"})
|
||||||
|
.dest(&outLink);
|
||||||
|
|
||||||
|
mkFlag()
|
||||||
|
.longName("no-link")
|
||||||
|
.description("do not create a symlink to the build result")
|
||||||
|
.set(&outLink, Path(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string name() override
|
std::string name() override
|
||||||
|
@ -28,14 +42,14 @@ struct CmdBuild : MixDryRun, InstallablesCommand
|
||||||
for (size_t i = 0; i < buildables.size(); ++i) {
|
for (size_t i = 0; i < buildables.size(); ++i) {
|
||||||
auto & b(buildables[i]);
|
auto & b(buildables[i]);
|
||||||
|
|
||||||
for (auto & output : b.outputs) {
|
if (outLink != "")
|
||||||
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>()) {
|
for (auto & output : b.outputs)
|
||||||
std::string symlink = "result";
|
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>()) {
|
||||||
if (i) symlink += fmt("-%d", i);
|
std::string symlink = outLink;
|
||||||
if (output.first != "out") symlink += fmt("-%s", output.first);
|
if (i) symlink += fmt("-%d", i);
|
||||||
store2->addPermRoot(output.second, absPath(symlink), true);
|
if (output.first != "out") symlink += fmt("-%s", output.first);
|
||||||
}
|
store2->addPermRoot(output.second, absPath(symlink), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@ struct CmdCopy : StorePathsCommand
|
||||||
mkFlag()
|
mkFlag()
|
||||||
.longName("no-check-sigs")
|
.longName("no-check-sigs")
|
||||||
.description("do not require that paths are signed by trusted keys")
|
.description("do not require that paths are signed by trusted keys")
|
||||||
.handler([&](Strings ss) { checkSigs = NoCheckSigs; });
|
.set(&checkSigs, NoCheckSigs);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string name() override
|
std::string name() override
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct CmdRun : InstallablesCommand
|
||||||
.longName("ignore-environment")
|
.longName("ignore-environment")
|
||||||
.shortName('i')
|
.shortName('i')
|
||||||
.description("clear the entire environment (except those specified with --keep)")
|
.description("clear the entire environment (except those specified with --keep)")
|
||||||
.handler([&](Strings ss) { ignoreEnvironment = true; });
|
.set(&ignoreEnvironment, true);
|
||||||
|
|
||||||
mkFlag()
|
mkFlag()
|
||||||
.longName("keep")
|
.longName("keep")
|
||||||
|
|
Loading…
Reference in a new issue