1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-30 19:57:59 +02:00

Add --update-input flag to update a specific flake input

Typical usage:

  $ nix flake update ~/Misc/eelco-configurations/hagbard --update-input nixpkgs

to update the 'nixpkgs' input of a flake while leaving every other
input unchanged.

The argument is an input path, so you can do e.g. '--update-input
dwarffs/nixpkgs' to update an input of an input.

Fixes #2928.
This commit is contained in:
Eelco Dolstra 2020-01-29 23:12:58 +01:00
parent 88b44b1e94
commit b9fb372075
6 changed files with 76 additions and 15 deletions

View file

@ -72,6 +72,22 @@ std::optional<LockedInput *> LockedInputs::findInput(const InputPath & path)
return (LockedInput *) pos;
}
void LockedInputs::removeInput(const InputPath & path)
{
assert(!path.empty());
LockedInputs * pos = this;
for (size_t n = 0; n < path.size(); n++) {
auto i = pos->inputs.find(path[n]);
if (i == pos->inputs.end()) return;
if (n + 1 == path.size())
pos->inputs.erase(i);
else
pos = &i->second;
}
}
nlohmann::json LockFile::toJson() const
{
auto json = LockedInputs::toJson();