mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 23:12:44 +01:00
nix copy: Add --out-link
This commit is contained in:
parent
43ad8c5eb2
commit
7f6d006beb
7 changed files with 66 additions and 25 deletions
|
|
@ -334,4 +334,29 @@ void MixEnvironment::setEnviron()
|
|||
}
|
||||
}
|
||||
|
||||
void createOutLinks(
|
||||
const std::filesystem::path & outLink,
|
||||
const BuiltPaths & buildables,
|
||||
LocalFSStore & store)
|
||||
{
|
||||
for (const auto & [_i, buildable] : enumerate(buildables)) {
|
||||
auto i = _i;
|
||||
std::visit(overloaded {
|
||||
[&](const BuiltPath::Opaque & bo) {
|
||||
auto symlink = outLink;
|
||||
if (i) symlink += fmt("-%d", i);
|
||||
store.addPermRoot(bo.path, absPath(symlink.string()));
|
||||
},
|
||||
[&](const BuiltPath::Built & bfd) {
|
||||
for (auto & output : bfd.outputs) {
|
||||
auto symlink = outLink;
|
||||
if (i) symlink += fmt("-%d", i);
|
||||
if (output.first != "out") symlink += fmt("-%s", output.first);
|
||||
store.addPermRoot(output.second, absPath(symlink.string()));
|
||||
}
|
||||
},
|
||||
}, buildable.raw());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ extern char * * savedArgv;
|
|||
class EvalState;
|
||||
struct Pos;
|
||||
class Store;
|
||||
class LocalFSStore;
|
||||
|
||||
static constexpr Command::Category catHelp = -1;
|
||||
static constexpr Command::Category catSecondary = 100;
|
||||
|
|
@ -367,4 +368,13 @@ void printClosureDiff(
|
|||
const StorePath & afterPath,
|
||||
std::string_view indent);
|
||||
|
||||
/**
|
||||
* Create symlinks prefixed by `outLink` to the store paths in
|
||||
* `buildables`.
|
||||
*/
|
||||
void createOutLinks(
|
||||
const std::filesystem::path & outLink,
|
||||
const BuiltPaths & buildables,
|
||||
LocalFSStore & store);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -917,4 +917,12 @@ void BuiltPathsCommand::applyDefaultInstallables(std::vector<std::string> & rawI
|
|||
rawInstallables.push_back(".");
|
||||
}
|
||||
|
||||
BuiltPaths toBuiltPaths(const std::vector<BuiltPathWithResult> & builtPathsWithResult)
|
||||
{
|
||||
BuiltPaths res;
|
||||
for (auto & i : builtPathsWithResult)
|
||||
res.push_back(i.path);
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ struct BuiltPathWithResult
|
|||
std::optional<BuildResult> result;
|
||||
};
|
||||
|
||||
BuiltPaths toBuiltPaths(const std::vector<BuiltPathWithResult> & builtPathsWithResult);
|
||||
|
||||
/**
|
||||
* Shorthand, for less typing and helping us keep the choice of
|
||||
* collection in sync.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue