nix-super/src/libfetchers/registry.hh

63 lines
1.3 KiB
C++
Raw Normal View History

#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
2020-03-17 21:54:36 +02:00
Attrs // extra attributes
>
> entries;
2020-01-22 21:00:58 +02:00
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,
2020-03-17 21:54:36 +02:00
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);
2020-01-22 21:00:58 +02:00
void overrideRegistry(
const std::shared_ptr<const Input> & from,
const std::shared_ptr<const Input> & to,
2020-03-17 21:54:36 +02:00
const Attrs & extraAttrs);
2020-01-22 21:00:58 +02:00
2020-03-17 21:54:36 +02:00
std::pair<std::shared_ptr<const Input>, Attrs> lookupInRegistries(
ref<Store> store,
std::shared_ptr<const Input> input);
}