From 52c0ef24c5be1cd539d28b9a5368673c56078154 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 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); }