diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index e4386be0b25..9131e89c338 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -1705,7 +1705,10 @@ static std::string_view legacyBaseNameOf(std::string_view path) static void prim_baseNameOf(EvalState & state, const PosIdx pos, Value * * args, Value & v) { NixStringContext context; - v.mkString(legacyBaseNameOf(*state.coerceToString(pos, *args[0], context, + if (v.type() == nPath) + v.mkString(baseNameOf(v.path().path.abs()), context); + else + v.mkString(legacyBaseNameOf(*state.coerceToString(pos, *args[0], context, "while evaluating the first argument passed to builtins.baseNameOf", false, false)), context); }