mirror of
https://github.com/NixOS/nix
synced 2025-06-28 09:31:16 +02:00
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.
This commit is contained in:
parent
f201b7733e
commit
88cd2d41ac
24 changed files with 122 additions and 3 deletions
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue