2020-01-21 15:27:53 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "types.hh"
|
2020-02-20 21:14:44 +00:00
|
|
|
#include "fetchers.hh"
|
2020-01-21 15:27:53 +00:00
|
|
|
|
|
|
|
namespace nix { class Store; }
|
|
|
|
|
|
|
|
namespace nix::fetchers {
|
|
|
|
|
|
|
|
struct Registry
|
|
|
|
{
|
|
|
|
enum RegistryType {
|
|
|
|
Flag = 0,
|
|
|
|
User = 1,
|
2020-04-01 20:56:50 +00:00
|
|
|
System = 2,
|
|
|
|
Global = 3,
|
2020-01-21 15:27:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
RegistryType type;
|
|
|
|
|
2020-02-20 21:14:44 +00:00
|
|
|
std::vector<
|
|
|
|
std::tuple<
|
|
|
|
std::shared_ptr<const Input>, // from
|
|
|
|
std::shared_ptr<const Input>, // to
|
2020-03-17 19:54:36 +00:00
|
|
|
Attrs // extra attributes
|
2020-02-20 21:14:44 +00:00
|
|
|
>
|
|
|
|
> entries;
|
2020-01-21 15:27:53 +00:00
|
|
|
|
2020-01-22 19:00:58 +00:00
|
|
|
Registry(RegistryType type)
|
|
|
|
: type(type)
|
|
|
|
{ }
|
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
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,
|
2020-02-20 21:14:44 +00:00
|
|
|
const std::shared_ptr<const Input> & to,
|
2020-03-17 19:54:36 +00:00
|
|
|
const Attrs & extraAttrs);
|
2020-01-21 15:27:53 +00:00
|
|
|
|
|
|
|
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 19:00:58 +00:00
|
|
|
void overrideRegistry(
|
|
|
|
const std::shared_ptr<const Input> & from,
|
2020-02-20 21:14:44 +00:00
|
|
|
const std::shared_ptr<const Input> & to,
|
2020-03-17 19:54:36 +00:00
|
|
|
const Attrs & extraAttrs);
|
2020-01-22 19:00:58 +00:00
|
|
|
|
2020-03-17 19:54:36 +00:00
|
|
|
std::pair<std::shared_ptr<const Input>, Attrs> lookupInRegistries(
|
2020-01-21 15:27:53 +00:00
|
|
|
ref<Store> store,
|
|
|
|
std::shared_ptr<const Input> input);
|
|
|
|
|
|
|
|
}
|