split <2.34 code in cmake
This commit is contained in:
parent
df23fb0436
commit
70b537244d
2 changed files with 23 additions and 9 deletions
|
|
@ -8,4 +8,9 @@ add_library(nix-scope-plugin MODULE scope.cc)
|
|||
target_link_libraries(nix-scope-plugin PkgConfig::NIX_EXPR)
|
||||
set_target_properties(nix-scope-plugin PROPERTIES PREFIX "lib")
|
||||
|
||||
if(NIX_EXPR_VERSION VERSION_LESS "2.34")
|
||||
target_compile_definitions(nix-scope-plugin PRIVATE NIX_PRE_234)
|
||||
endif()
|
||||
message(STATUS "Building nix-scope-plugin against nix-expr ${NIX_EXPR_VERSION}")
|
||||
|
||||
install(TARGETS nix-scope-plugin DESTINATION lib/nix/plugins)
|
||||
|
|
|
|||
27
scope.cc
27
scope.cc
|
|
@ -40,13 +40,22 @@ static void prim_scope(EvalState & state, const PosIdx pos, Value ** args, Value
|
|||
v = *inner;
|
||||
}
|
||||
|
||||
static RegisterPrimOp rp(PrimOp{
|
||||
.name = "scope",
|
||||
.args = {"path", "value"},
|
||||
.doc = R"(
|
||||
Construct a nested attribute set from a dotted string path and a value.
|
||||
static RegisterPrimOp rp(
|
||||
#ifndef NIX_PRE_234
|
||||
PrimOp
|
||||
#endif
|
||||
{
|
||||
.name = "scope",
|
||||
.args = {"path", "value"},
|
||||
.doc = R"(
|
||||
Construct a nested attribute set from a dotted string path and a value.
|
||||
|
||||
Example: `scope "a.b.c" 42` evaluates to `{ a = { b = { c = 42; }; }; }`.
|
||||
)",
|
||||
.impl = prim_scope,
|
||||
});
|
||||
Example: `scope "a.b.c" 42` evaluates to `{ a = { b = { c = 42; }; }; }`.
|
||||
)",
|
||||
#ifdef NIX_PRE_234
|
||||
.fun = prim_scope,
|
||||
#else
|
||||
.impl = prim_scope,
|
||||
#endif
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue