aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/platform.cc
diff options
context:
space:
mode:
authorArtemis Tosini <lix@artem.ist>2024-04-22 17:32:21 +0000
committerArtemis Tosini <lix@artem.ist>2024-04-23 16:17:05 +0000
commitb247ef72dc7bcc857288c0ddcceb3e42f76a78f1 (patch)
tree01ec226e6f1e030797bde73bac219c2eb87e7c00 /src/libstore/platform.cc
parentc8c838381d8e76450ffd57b778bb28217b32084d (diff)
libstore: Create platform LocalStore subclasses
This creates new subclasses of LocalStore for each OS to include platform-specific functionality. Currently this just includes garbage collector roots but it could be extended to sandboxing as well. In order to make sure that the generic LocalStore is not accidentally constructed, its constructor is protected. A Fallback is provided which implements no functionality except constructors. Change-Id: I836a28e90b68309873f75afb83e0f1b2e2c89fb3
Diffstat (limited to 'src/libstore/platform.cc')
-rw-r--r--src/libstore/platform.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libstore/platform.cc b/src/libstore/platform.cc
new file mode 100644
index 000000000..9c389ef55
--- /dev/null
+++ b/src/libstore/platform.cc
@@ -0,0 +1,18 @@
+#include "local-store.hh"
+
+#if __linux__
+#include "platform/linux.hh"
+#else
+#include "platform/fallback.hh"
+#endif
+
+namespace nix {
+std::shared_ptr<LocalStore> LocalStore::makeLocalStore(const Params & params)
+{
+#if __linux__
+ return std::shared_ptr<LocalStore>(new LinuxLocalStore(params));
+#else
+ return std::shared_ptr<LocalStore>(new FallbackLocalStore(params));
+#endif
+}
+}