diff options
author | Robert Hensing <robert@roberthensing.nl> | 2022-12-19 14:06:07 +0100 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2022-12-24 14:39:30 +0100 |
commit | aba6eb348e0ed8177da1e7f1df46ba00d20eab96 (patch) | |
tree | 50bb1337cafac6b3a1389d43fd033d97a13c09f9 /src/libstore/globals.cc | |
parent | 26c7602c390f8c511f326785b570918b2f468892 (diff) |
libstore: Make sure that initNix has been called
Prevent bugs like https://github.com/cachix/cachix/pull/477
Diffstat (limited to 'src/libstore/globals.cc')
-rw-r--r-- | src/libstore/globals.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index b7f55cae7..130c5b670 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -291,4 +291,18 @@ void initPlugins() settings.pluginFiles.pluginsLoaded = true; } +static bool initLibStoreDone = false; + +void assertLibStoreInitialized() { + if (!initLibStoreDone) { + printError("The program must call nix::initNix() before calling any libstore library functions."); + abort(); + }; +} + +void initLibStore() { + initLibStoreDone = true; +} + + } |