From ed16517bf1343084892b76a1cd8587370a545eb6 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 8 Aug 2024 12:42:26 +0200 Subject: [PATCH] WIP fix baseNameOf (needs test maybe) https://github.com/NixOS/nix/pull/10252#issuecomment-2275035429 --- src/libexpr/primops.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index f971e191205..a688e3f544f 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -1704,7 +1704,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); }