about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2018-02-08T16·26-0500
committerShea Levy <shea@shealevy.com>2018-02-08T17·44-0500
commit88cd2d41acb994684a3e4ead1b1676019f43b4b6 (patch)
tree7385aefa5755fd27983f3260b69020acef6de170 /tests
parentf201b7733e22cc236a41093a88cc789239d994bd (diff)
Add plugins to make Nix more extensible.
All plugins in plugin-files will be dlopened, allowing them to
statically construct instances of the various Register* types Nix
supports.
Diffstat (limited to 'tests')
-rw-r--r--tests/local.mk5
-rw-r--r--tests/plugins.sh7
-rw-r--r--tests/plugins/local.mk9
-rw-r--r--tests/plugins/plugintest.cc10
4 files changed, 29 insertions, 2 deletions
diff --git a/tests/local.mk b/tests/local.mk
index e90b9f7da4ad..51bc09dd4322 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -22,7 +22,8 @@ nix_tests = \
   run.sh \
   brotli.sh \
   pure-eval.sh \
-  check.sh
+  check.sh \
+  plugins.sh
   # parallel.sh
 
 install-tests += $(foreach x, $(nix_tests), tests/$(x))
@@ -31,4 +32,4 @@ tests-environment = NIX_REMOTE= $(bash) -e
 
 clean-files += $(d)/common.sh
 
-installcheck: $(d)/common.sh
+installcheck: $(d)/common.sh $(d)/plugins/plugintest.so
diff --git a/tests/plugins.sh b/tests/plugins.sh
new file mode 100644
index 000000000000..6d18d1da0d18
--- /dev/null
+++ b/tests/plugins.sh
@@ -0,0 +1,7 @@
+source common.sh
+
+set -o pipefail
+
+res=$(nix eval '(builtins.constNull true)' --option plugin-files $PWD/plugins/plugintest.so)
+
+[ "$res"x = "nullx" ]
diff --git a/tests/plugins/local.mk b/tests/plugins/local.mk
new file mode 100644
index 000000000000..a5f19b087c82
--- /dev/null
+++ b/tests/plugins/local.mk
@@ -0,0 +1,9 @@
+libraries += plugintest
+
+plugintest_DIR := $(d)
+
+plugintest_SOURCES := $(d)/plugintest.cc
+
+plugintest_ALLOW_UNDEFINED := 1
+
+plugintest_EXCLUDE_FROM_LIBRARY_LIST := 1
diff --git a/tests/plugins/plugintest.cc b/tests/plugins/plugintest.cc
new file mode 100644
index 000000000000..f788c4814322
--- /dev/null
+++ b/tests/plugins/plugintest.cc
@@ -0,0 +1,10 @@
+#include "primops.hh"
+
+using namespace nix;
+
+static void prim_constNull (EvalState & state, const Pos & pos, Value ** args, Value & v)
+{
+    mkNull(v);
+}
+
+static RegisterPrimOp r("constNull", 1, prim_constNull);