aboutsummaryrefslogtreecommitdiff
path: root/src/libfetchers/registry.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libfetchers/registry.hh')
-rw-r--r--src/libfetchers/registry.hh65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/libfetchers/registry.hh b/src/libfetchers/registry.hh
new file mode 100644
index 000000000..c3ce948a8
--- /dev/null
+++ b/src/libfetchers/registry.hh
@@ -0,0 +1,65 @@
+#pragma once
+
+#include "types.hh"
+#include "fetchers.hh"
+
+namespace nix { class Store; }
+
+namespace nix::fetchers {
+
+struct Registry
+{
+ enum RegistryType {
+ Flag = 0,
+ User = 1,
+ System = 2,
+ Global = 3,
+ };
+
+ RegistryType type;
+
+ struct Entry
+ {
+ std::shared_ptr<const Input> from;
+ std::shared_ptr<const Input> to;
+ Attrs extraAttrs;
+ bool exact = false;
+ };
+
+ std::vector<Entry> entries;
+
+ Registry(RegistryType type)
+ : type(type)
+ { }
+
+ static std::shared_ptr<Registry> read(
+ const Path & path, RegistryType type);
+
+ void write(const Path & path);
+
+ void add(
+ const std::shared_ptr<const Input> & from,
+ const std::shared_ptr<const Input> & to,
+ const Attrs & extraAttrs);
+
+ void remove(const std::shared_ptr<const Input> & input);
+};
+
+typedef std::vector<std::shared_ptr<Registry>> Registries;
+
+std::shared_ptr<Registry> getUserRegistry();
+
+Path getUserRegistryPath();
+
+Registries getRegistries(ref<Store> store);
+
+void overrideRegistry(
+ const std::shared_ptr<const Input> & from,
+ const std::shared_ptr<const Input> & to,
+ const Attrs & extraAttrs);
+
+std::pair<std::shared_ptr<const Input>, Attrs> lookupInRegistries(
+ ref<Store> store,
+ std::shared_ptr<const Input> input);
+
+}