Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libcmd/common-eval-args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ MixEvalArgs::MixEvalArgs()
fetchers::Attrs extraAttrs;
if (to.subdir != "")
extraAttrs["dir"] = to.subdir;
fetchers::overrideRegistry(fetchSettings, from.input, to.input, extraAttrs);
fetchers::overrideRegistry(from.input, to.input, extraAttrs);
}},
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
completeFlakeRef(completions, openStore(), prefix);
Expand Down
1 change: 0 additions & 1 deletion src/libcmd/installables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ MixFlakeOptions::MixFlakeOptions()
}

overrideRegistry(
fetchSettings,
fetchers::Input::fromAttrs(fetchSettings, {{"type", "indirect"}, {"id", inputName}}),
input3->lockedRef.input,
extraAttrs);
Expand Down
9 changes: 3 additions & 6 deletions src/libfetchers/include/nix/fetchers/registry.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ namespace nix::fetchers {

struct Registry
{
const Settings & settings;

enum RegistryType {
Flag = 0,
User = 1,
Expand All @@ -34,9 +32,8 @@ struct Registry

std::vector<Entry> entries;

Registry(const Settings & settings, RegistryType type)
: settings{settings}
, type{type}
Registry(RegistryType type)
: type{type}
{
}

Expand All @@ -59,7 +56,7 @@ Path getUserRegistryPath();

Registries getRegistries(const Settings & settings, Store & store);

void overrideRegistry(const Settings & settings, const Input & from, const Input & to, const Attrs & extraAttrs);
void overrideRegistry(const Input & from, const Input & to, const Attrs & extraAttrs);

enum class UseRegistries : int {
No,
Expand Down
16 changes: 8 additions & 8 deletions src/libfetchers/registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ std::shared_ptr<Registry> Registry::read(const Settings & settings, const Source
{
debug("reading registry '%s'", path);

auto registry = std::make_shared<Registry>(settings, type);
auto registry = std::make_shared<Registry>(type);

if (!path.pathExists())
return std::make_shared<Registry>(settings, type);
return std::make_shared<Registry>(type);

try {

Expand Down Expand Up @@ -125,23 +125,23 @@ std::shared_ptr<Registry> getCustomRegistry(const Settings & settings, const Pat
return customRegistry;
}

std::shared_ptr<Registry> getFlagRegistry(const Settings & settings)
std::shared_ptr<Registry> getFlagRegistry()
{
static auto flagRegistry = std::make_shared<Registry>(settings, Registry::Flag);
static auto flagRegistry = std::make_shared<Registry>(Registry::Flag);
return flagRegistry;
}

void overrideRegistry(const Settings & settings, const Input & from, const Input & to, const Attrs & extraAttrs)
void overrideRegistry(const Input & from, const Input & to, const Attrs & extraAttrs)
{
getFlagRegistry(settings)->add(from, to, extraAttrs);
getFlagRegistry()->add(from, to, extraAttrs);
}

static std::shared_ptr<Registry> getGlobalRegistry(const Settings & settings, Store & store)
{
static auto reg = [&]() {
auto path = settings.flakeRegistry.get();
if (path == "") {
return std::make_shared<Registry>(settings, Registry::Global); // empty registry
return std::make_shared<Registry>(Registry::Global); // empty registry
}

return Registry::read(
Expand All @@ -165,7 +165,7 @@ static std::shared_ptr<Registry> getGlobalRegistry(const Settings & settings, St
Registries getRegistries(const Settings & settings, Store & store)
{
Registries registries;
registries.push_back(getFlagRegistry(settings));
registries.push_back(getFlagRegistry());
registries.push_back(getUserRegistry(settings));
registries.push_back(getSystemRegistry(settings));
registries.push_back(getGlobalRegistry(settings, store));
Expand Down
Loading