about summary refs log tree commit diff
path: root/src/libstore/globals.cc
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 /src/libstore/globals.cc
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 'src/libstore/globals.cc')
-rw-r--r--src/libstore/globals.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
index d3c96ddd6e61..21ab0e6296ef 100644
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -6,6 +6,7 @@
 #include <algorithm>
 #include <map>
 #include <thread>
+#include <dlfcn.h>
 
 
 namespace nix {
@@ -137,4 +138,18 @@ void MaxBuildJobsSetting::set(const std::string & str)
         throw UsageError("configuration setting '%s' should be 'auto' or an integer", name);
 }
 
+
+void initPlugins()
+{
+    for (const auto & pluginFile : settings.pluginFiles.get()) {
+        /* handle is purposefully leaked as there may be state in the
+           DSO needed by the action of the plugin. */
+        void *handle =
+            dlopen(pluginFile.c_str(), RTLD_LAZY | RTLD_LOCAL);
+        if (!handle)
+            throw Error(format("could not dynamically open plugin file '%1%': %2%") % pluginFile % dlerror());
+    }
+}
+
+
 }