Add flake registry

This will eventually be moved to nixos.org.
This commit is contained in:
Eelco Dolstra 2019-02-11 13:01:39 +01:00
parent dcae46ab14
commit 52419f8db3
No known key found for this signature in database
GPG Key ID: 8170B4726D7198DE
3 changed files with 19 additions and 2 deletions

11
flake-registry.json Normal file
View File

@ -0,0 +1,11 @@
{
"version": 1,
"flakes": {
"dwarffs": {
"uri": "github:edolstra/dwarffs/flake"
},
"nixpkgs": {
"uri": "github:edolstra/nixpkgs/flake"
}
}
}

View File

@ -10,3 +10,5 @@ GLOBAL_CXXFLAGS += -I . -I src -I src/libutil -I src/libstore -I src/libmain -I
$(foreach i, config.h $(call rwildcard, src/lib*, *.hh), \
$(eval $(call install-file-in, $(i), $(includedir)/nix, 0644)))
$(eval $(call install-data-in,$(d)/flake-registry.json,$(datadir)/nix))

View File

@ -17,15 +17,19 @@ const EvalState::FlakeRegistry & EvalState::getFlakeRegistry()
if (!evalSettings.pureEval) {
#if 0
auto registryUri = "file:///home/eelco/Dev/gists/nix-flakes/registry.json";
auto registryFile = getDownloader()->download(DownloadRequest(registryUri));
#endif
auto json = nlohmann::json::parse(*registryFile.data);
auto registryFile = readFile(settings.nixDataDir + "/nix/flake-registry.json");
auto json = nlohmann::json::parse(registryFile);
auto version = json.value("version", 0);
if (version != 1)
throw Error("flake registry '%s' has unsupported version %d", registryUri, version);
throw Error("flake registry '%s' has unsupported version %d", registryFile, version);
auto flakes = json["flakes"];
for (auto i = flakes.begin(); i != flakes.end(); ++i) {