mirror of
https://github.com/NixOS/nix
synced 2025-07-08 02:43:54 +02:00
profile install: skip and warn on installing package twice
This commit is contained in:
parent
d28a240aa6
commit
14adff1711
2 changed files with 23 additions and 1 deletions
|
@ -395,7 +395,26 @@ struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile
|
|||
|
||||
element.updateStorePaths(getEvalStore(), store, res);
|
||||
|
||||
manifest.addElement(std::move(element));
|
||||
auto elementName = getNameFromElement(element);
|
||||
|
||||
// Check if the element already exists.
|
||||
auto existingPair = manifest.elements.find(elementName);
|
||||
if (existingPair != manifest.elements.end()) {
|
||||
auto existingElement = existingPair->second;
|
||||
auto existingSource = existingElement.source;
|
||||
auto elementSource = element.source;
|
||||
if (existingSource
|
||||
&& elementSource
|
||||
&& existingElement.priority == element.priority
|
||||
&& existingSource->originalRef == elementSource->originalRef
|
||||
&& existingSource->attrPath == elementSource->attrPath
|
||||
) {
|
||||
warn("'%s' is already installed", elementName);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
manifest.addElement(elementName, std::move(element));
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue