diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-03-30 14:03:28 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-03-30 14:04:53 +0200 |
commit | e0a0ae0467fa8cdcc542f593b9d94283f04508ff (patch) | |
tree | 9ee49c40c301f51c4f20a0d9ad2031c7de001100 /src/libfetchers/registry.hh | |
parent | 4ba4c7ff66c95319d98fa859428f60f30f94edd4 (diff) |
Move fetchers from libstore to libfetchers
Diffstat (limited to 'src/libfetchers/registry.hh')
-rw-r--r-- | src/libfetchers/registry.hh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/libfetchers/registry.hh b/src/libfetchers/registry.hh new file mode 100644 index 000000000..d2eb7749b --- /dev/null +++ b/src/libfetchers/registry.hh @@ -0,0 +1,62 @@ +#pragma once + +#include "types.hh" +#include "fetchers.hh" + +namespace nix { class Store; } + +namespace nix::fetchers { + +struct Registry +{ + enum RegistryType { + Flag = 0, + User = 1, + Global = 2, + }; + + RegistryType type; + + std::vector< + std::tuple< + std::shared_ptr<const Input>, // from + std::shared_ptr<const Input>, // to + Attrs // extra attributes + > + > 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); + +} |