1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-24 09:50:55 +01:00

libcmd: improve --override-input error message clarity

Make the error message more explicit about what went wrong and why
it's invalid. The new message explains that a zero-length path was
passed and clarifies that it would refer to the flake itself.
This commit is contained in:
Robert Hensing 2025-12-20 02:09:57 +01:00
parent bec436c0b1
commit b1a230de75
2 changed files with 3 additions and 2 deletions

View file

@ -137,7 +137,8 @@ MixFlakeOptions::MixFlakeOptions()
lockFlags.writeLockFile = false;
auto path = flake::NonEmptyInputAttrPath::parse(inputAttrPath);
if (!path)
throw UsageError("--override-input: input path cannot be empty");
throw UsageError(
"--override-input was passed a zero-length input path, which would refer to the flake itself, not an input");
lockFlags.inputOverrides.insert_or_assign(
std::move(*path), parseFlakeRef(fetchSettings, flakeRef, absPath(getCommandBaseDir()).string(), true));
}},

View file

@ -396,7 +396,7 @@ nix flake lock "$flake3Dir" --override-input flake2/flake1 flake1/master/"$hash1
[[ $(jq -r .nodes.flake1_2.locked.rev "$flake3Dir/flake.lock") =~ $hash1 ]]
# Test that --override-input with empty input path is rejected (issue #14816).
expectStderr 1 nix flake lock "$flake3Dir" --override-input '' . | grepQuiet "input path cannot be empty"
expectStderr 1 nix flake lock "$flake3Dir" --override-input '' . | grepQuiet -- "--override-input was passed a zero-length input path, which would refer to the flake itself, not an input"
# Test that deprecated --update-input with empty input path is rejected.
expectStderr 1 nix flake lock "$flake3Dir" --update-input '' | grepQuiet -- "--update-input was passed a zero-length input path, which would refer to the flake itself, not an input"