aboutsummaryrefslogtreecommitdiff
path: root/src/libfetchers
diff options
context:
space:
mode:
authorjulia <midnight@trainwit.ch>2024-05-15 19:11:32 +1000
committerjulia <midnight@trainwit.ch>2024-05-18 12:27:23 +1000
commit7a3745b07607d3fc85fb5a0a08832ab078080884 (patch)
treebc82a0a28077bb320a7a32c9d4bc7de9b213b47d /src/libfetchers
parent236466faf385f98f3639ec04147c171774d03726 (diff)
Deprecate the online flake registries and vendor the default registry
Fixes #183, #110, #116. The default flake-registry option becomes 'vendored', and refers to a vendored flake-registry.json file in the install path. Vendored copy of the flake-registry is from github:NixOS/flake-registry at commit 9c69f7bd2363e71fe5cd7f608113290c7614dcdd. Change-Id: I752b81c85ebeaab4e582ac01c239d69d65580f37
Diffstat (limited to 'src/libfetchers')
-rw-r--r--src/libfetchers/fetch-settings.hh5
-rw-r--r--src/libfetchers/registry.cc10
2 files changed, 13 insertions, 2 deletions
diff --git a/src/libfetchers/fetch-settings.hh b/src/libfetchers/fetch-settings.hh
index 6108a179c..c67a75082 100644
--- a/src/libfetchers/fetch-settings.hh
+++ b/src/libfetchers/fetch-settings.hh
@@ -71,10 +71,13 @@ struct FetchSettings : public Config
Setting<bool> warnDirty{this, true, "warn-dirty",
"Whether to warn about dirty Git/Mercurial trees."};
- Setting<std::string> flakeRegistry{this, "https://channels.nixos.org/flake-registry.json", "flake-registry",
+ Setting<std::string> flakeRegistry{this, "vendored", "flake-registry",
R"(
Path or URI of the global flake registry.
+ URIs are deprecated. When set to 'vendored', defaults to a vendored
+ copy of https://channels.nixos.org/flake-registry.json.
+
When empty, disables the global flake registry.
)",
{}, true, Xp::Flakes};
diff --git a/src/libfetchers/registry.cc b/src/libfetchers/registry.cc
index da92273d6..4b2d61f52 100644
--- a/src/libfetchers/registry.cc
+++ b/src/libfetchers/registry.cc
@@ -16,8 +16,12 @@ std::shared_ptr<Registry> Registry::read(
{
auto registry = std::make_shared<Registry>(type);
- if (!pathExists(path))
+ if (!pathExists(path)) {
+ if (type == RegistryType::Global) {
+ warn("cannot read flake registry '%s': path does not exist", path);
+ }
return std::make_shared<Registry>(type);
+ }
try {
@@ -155,9 +159,13 @@ static std::shared_ptr<Registry> getGlobalRegistry(ref<Store> store)
auto path = fetchSettings.flakeRegistry.get();
if (path == "") {
return std::make_shared<Registry>(Registry::Global); // empty registry
+ } else if (path == "vendored") {
+ return Registry::read(settings.nixDataDir + "/flake-registry.json", Registry::Global);
}
if (!path.starts_with("/")) {
+ warn("config option flake-registry referring to a URL is deprecated and will be removed in Lix 3.0; yours is: `%s'", path);
+
auto storePath = downloadFile(store, path, "flake-registry.json", false).storePath;
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>())
store2->addPermRoot(storePath, getCacheDir() + "/nix/flake-registry.json");