lix/src/libfetchers/registry.hh
Eelco Dolstra 74024515a3 Support registry entries that must match exactly
An example use is for pinning the "nixpkgs" entry the system-wide
registry to a particular store path. Inexact matches
(e.g. "nixpkgs/master") should still use the global registry.
2020-04-01 23:12:45 +02:00

66 lines
1.3 KiB
C++

#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);
}