about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libstore/store-api.cc34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index d7b784cfbc20..db2e023ab0bf 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -795,33 +795,27 @@ static RegisterStoreImplementation regStore([](
 
 std::list<ref<Store>> getDefaultSubstituters()
 {
-    struct State {
-        bool done = false;
+    static auto stores([]() {
         std::list<ref<Store>> stores;
-    };
-    static Sync<State> state_;
-
-    auto state(state_.lock());
 
-    if (state->done) return state->stores;
+        StringSet done;
 
-    StringSet done;
-
-    auto addStore = [&](const std::string & uri) {
-        if (done.count(uri)) return;
-        done.insert(uri);
-        state->stores.push_back(openStore(uri));
-    };
+        auto addStore = [&](const std::string & uri) {
+            if (done.count(uri)) return;
+            done.insert(uri);
+            stores.push_back(openStore(uri));
+        };
 
-    for (auto uri : settings.substituters.get())
-        addStore(uri);
+        for (auto uri : settings.substituters.get())
+            addStore(uri);
 
-    for (auto uri : settings.extraSubstituters.get())
-        addStore(uri);
+        for (auto uri : settings.extraSubstituters.get())
+            addStore(uri);
 
-    state->done = true;
+        return stores;
+    } ());
 
-    return state->stores;
+    return stores;
 }