From b1a230de7547751e612fcfb5cc06baab4119bfa0 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sat, 20 Dec 2025 02:09:57 +0100 Subject: [PATCH] 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. --- src/libcmd/installables.cc | 3 ++- tests/functional/flakes/flakes.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc index 50f904e91..415d63d87 100644 --- a/src/libcmd/installables.cc +++ b/src/libcmd/installables.cc @@ -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)); }}, diff --git a/tests/functional/flakes/flakes.sh b/tests/functional/flakes/flakes.sh index 85357bf2a..1d5546d1b 100755 --- a/tests/functional/flakes/flakes.sh +++ b/tests/functional/flakes/flakes.sh @@ -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"