From fd273186c6dd32e6b61c71b57a350bec462e3cd6 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Wed, 19 Nov 2025 23:44:25 +0100 Subject: [PATCH] libexpr/builtins: Document appendContext Change-Id: Ic45e0d4f6f1646552a7162bd8916f63fc11e5e62 --- lix/libexpr/builtins/appendContext.md | 6 ++++++ lix/libexpr/extra-primops.hh | 1 + lix/libexpr/meson.build | 1 + lix/libexpr/primops/context.cc | 9 +-------- 4 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 lix/libexpr/builtins/appendContext.md diff --git a/lix/libexpr/builtins/appendContext.md b/lix/libexpr/builtins/appendContext.md new file mode 100644 index 000000000..8087cebb4 --- /dev/null +++ b/lix/libexpr/builtins/appendContext.md @@ -0,0 +1,6 @@ +--- +name: appendContext +args: [s, ctx] +--- + +Appends the attribute set `ctx` as a context to the string `s`, see [`getContext`](#builtins-getContext) for details on the format of the context. diff --git a/lix/libexpr/extra-primops.hh b/lix/libexpr/extra-primops.hh index 8743bb6e6..fcaa5af7c 100644 --- a/lix/libexpr/extra-primops.hh +++ b/lix/libexpr/extra-primops.hh @@ -14,6 +14,7 @@ void prim_fetchGit(EvalState & state, Value * * args, Value & v); void prim_fetchTarball(EvalState & state, Value * * args, Value & v); void prim_fetchurl(EvalState & state, Value * * args, Value & v); void prim_fromTOML(EvalState & state, Value * * args, Value & v); +void prim_appendContext(EvalState & state, Value ** args, Value & v); void prim_getContext(EvalState & state, Value * * args, Value & v); void prim_hasContext(EvalState & state, Value * * args, Value & v); void prim_unsafeDiscardOutputDependency(EvalState & state, Value * * args, Value & v); diff --git a/lix/libexpr/meson.build b/lix/libexpr/meson.build index c33d35022..ddee2e0bb 100644 --- a/lix/libexpr/meson.build +++ b/lix/libexpr/meson.build @@ -56,6 +56,7 @@ builtin_definitions = files( 'builtins/addErrorContext.md', 'builtins/all.md', 'builtins/any.md', + 'builtins/appendContext.md', 'builtins/attrNames.md', 'builtins/attrValues.md', 'builtins/baseNameOf.md', diff --git a/lix/libexpr/primops/context.cc b/lix/libexpr/primops/context.cc index eafff763d..2c6e2baa4 100644 --- a/lix/libexpr/primops/context.cc +++ b/lix/libexpr/primops/context.cc @@ -165,7 +165,7 @@ void prim_getContext(EvalState & state, Value * * args, Value & v) See the commentary above unsafeGetContext for details of the context representation. */ -static void prim_appendContext(EvalState & state, Value * * args, Value & v) +void prim_appendContext(EvalState & state, Value ** args, Value & v) { NixStringContext context; auto orig = state.forceString(*args[0], context, noPos, "while evaluating the first argument passed to builtins.appendContext"); @@ -241,11 +241,4 @@ static void prim_appendContext(EvalState & state, Value * * args, Value & v) v.mkString(orig, context); } - -static RegisterPrimOp primop_appendContext({ - .name = "__appendContext", - .arity = 2, - .fun = prim_appendContext -}); - }