2020-03-30 12:03:28 +00:00
|
|
|
#include "registry.hh"
|
|
|
|
#include "fetchers.hh"
|
2020-01-21 15:27:53 +00:00
|
|
|
#include "util.hh"
|
|
|
|
#include "globals.hh"
|
2020-03-18 13:08:25 +00:00
|
|
|
#include "store-api.hh"
|
2020-01-21 15:27:53 +00:00
|
|
|
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
|
|
|
|
namespace nix::fetchers {
|
|
|
|
|
|
|
|
std::shared_ptr<Registry> Registry::read(
|
|
|
|
const Path & path, RegistryType type)
|
|
|
|
{
|
2020-01-22 19:00:58 +00:00
|
|
|
auto registry = std::make_shared<Registry>(type);
|
2020-01-21 15:27:53 +00:00
|
|
|
|
|
|
|
if (!pathExists(path))
|
2020-01-22 19:00:58 +00:00
|
|
|
return std::make_shared<Registry>(type);
|
2020-01-21 15:27:53 +00:00
|
|
|
|
2020-04-02 17:09:17 +00:00
|
|
|
try {
|
2020-01-21 15:27:53 +00:00
|
|
|
|
2020-04-02 17:09:17 +00:00
|
|
|
auto json = nlohmann::json::parse(readFile(path));
|
2020-01-21 15:27:53 +00:00
|
|
|
|
2020-04-02 17:09:17 +00:00
|
|
|
auto version = json.value("version", 0);
|
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
if (version == 2) {
|
2020-04-02 17:09:17 +00:00
|
|
|
for (auto & i : json["flakes"]) {
|
|
|
|
auto toAttrs = jsonToAttrs(i["to"]);
|
|
|
|
Attrs extraAttrs;
|
|
|
|
auto j = toAttrs.find("dir");
|
|
|
|
if (j != toAttrs.end()) {
|
|
|
|
extraAttrs.insert(*j);
|
|
|
|
toAttrs.erase(j);
|
|
|
|
}
|
|
|
|
auto exact = i.find("exact");
|
|
|
|
registry->entries.push_back(
|
|
|
|
Entry {
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
.from = Input::fromAttrs(jsonToAttrs(i["from"])),
|
|
|
|
.to = Input::fromAttrs(std::move(toAttrs)),
|
2020-04-02 17:09:17 +00:00
|
|
|
.extraAttrs = extraAttrs,
|
|
|
|
.exact = exact != i.end() && exact.value()
|
|
|
|
});
|
2020-02-20 21:14:44 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-21 15:27:53 +00:00
|
|
|
|
2020-04-02 17:09:17 +00:00
|
|
|
else
|
|
|
|
throw Error("flake registry '%s' has unsupported version %d", path, version);
|
2020-02-06 13:27:31 +00:00
|
|
|
|
2020-04-02 17:09:17 +00:00
|
|
|
} catch (nlohmann::json::exception & e) {
|
|
|
|
warn("cannot parse flake registry '%s': %s", path, e.what());
|
2020-04-14 15:25:39 +00:00
|
|
|
} catch (Error & e) {
|
|
|
|
warn("cannot read flake registry '%s': %s", path, e.what());
|
2020-04-02 17:09:17 +00:00
|
|
|
}
|
2020-02-06 13:27:31 +00:00
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
return registry;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Registry::write(const Path & path)
|
|
|
|
{
|
2020-02-06 13:27:31 +00:00
|
|
|
nlohmann::json arr;
|
2020-04-01 21:03:27 +00:00
|
|
|
for (auto & entry : entries) {
|
2020-02-06 13:27:31 +00:00
|
|
|
nlohmann::json obj;
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
obj["from"] = attrsToJson(entry.from.toAttrs());
|
|
|
|
obj["to"] = attrsToJson(entry.to.toAttrs());
|
2020-04-01 21:03:27 +00:00
|
|
|
if (!entry.extraAttrs.empty())
|
|
|
|
obj["to"].update(attrsToJson(entry.extraAttrs));
|
2020-04-01 21:12:45 +00:00
|
|
|
if (entry.exact)
|
|
|
|
obj["exact"] = true;
|
2020-02-06 13:27:31 +00:00
|
|
|
arr.emplace_back(std::move(obj));
|
|
|
|
}
|
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
nlohmann::json json;
|
2020-02-06 13:27:31 +00:00
|
|
|
json["version"] = 2;
|
|
|
|
json["flakes"] = std::move(arr);
|
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
createDirs(dirOf(path));
|
2020-02-06 13:27:31 +00:00
|
|
|
writeFile(path, json.dump(2));
|
2020-01-21 15:27:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Registry::add(
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
const Input & from,
|
|
|
|
const Input & to,
|
2020-03-17 19:54:36 +00:00
|
|
|
const Attrs & extraAttrs)
|
2020-01-21 15:27:53 +00:00
|
|
|
{
|
2020-04-01 21:03:27 +00:00
|
|
|
entries.emplace_back(
|
|
|
|
Entry {
|
|
|
|
.from = from,
|
|
|
|
.to = to,
|
|
|
|
.extraAttrs = extraAttrs
|
|
|
|
});
|
2020-01-21 15:27:53 +00:00
|
|
|
}
|
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
void Registry::remove(const Input & input)
|
2020-01-21 15:27:53 +00:00
|
|
|
{
|
|
|
|
// FIXME: use C++20 std::erase.
|
|
|
|
for (auto i = entries.begin(); i != entries.end(); )
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
if (i->from == input)
|
2020-01-21 15:27:53 +00:00
|
|
|
i = entries.erase(i);
|
|
|
|
else
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2020-04-01 20:56:50 +00:00
|
|
|
static Path getSystemRegistryPath()
|
|
|
|
{
|
|
|
|
return settings.nixConfDir + "/registry.json";
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::shared_ptr<Registry> getSystemRegistry()
|
|
|
|
{
|
|
|
|
static auto systemRegistry =
|
|
|
|
Registry::read(getSystemRegistryPath(), Registry::System);
|
|
|
|
return systemRegistry;
|
|
|
|
}
|
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
Path getUserRegistryPath()
|
|
|
|
{
|
|
|
|
return getHome() + "/.config/nix/registry.json";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<Registry> getUserRegistry()
|
|
|
|
{
|
2020-04-01 20:56:50 +00:00
|
|
|
static auto userRegistry =
|
|
|
|
Registry::read(getUserRegistryPath(), Registry::User);
|
|
|
|
return userRegistry;
|
2020-01-21 15:27:53 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 19:00:58 +00:00
|
|
|
static std::shared_ptr<Registry> flagRegistry =
|
|
|
|
std::make_shared<Registry>(Registry::Flag);
|
|
|
|
|
|
|
|
std::shared_ptr<Registry> getFlagRegistry()
|
2020-01-21 15:27:53 +00:00
|
|
|
{
|
|
|
|
return flagRegistry;
|
|
|
|
}
|
2020-01-22 19:00:58 +00:00
|
|
|
|
|
|
|
void overrideRegistry(
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
const Input & from,
|
|
|
|
const Input & to,
|
2020-03-17 19:54:36 +00:00
|
|
|
const Attrs & extraAttrs)
|
2020-01-22 19:00:58 +00:00
|
|
|
{
|
2020-02-20 21:14:44 +00:00
|
|
|
flagRegistry->add(from, to, extraAttrs);
|
2020-01-22 19:00:58 +00:00
|
|
|
}
|
2020-01-21 15:27:53 +00:00
|
|
|
|
|
|
|
static std::shared_ptr<Registry> getGlobalRegistry(ref<Store> store)
|
|
|
|
{
|
|
|
|
static auto reg = [&]() {
|
2020-05-10 19:50:32 +00:00
|
|
|
auto path = settings.flakeRegistry.get();
|
2020-01-21 15:27:53 +00:00
|
|
|
|
2020-03-19 10:45:34 +00:00
|
|
|
if (!hasPrefix(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", true);
|
|
|
|
path = store->toRealPath(storePath);
|
|
|
|
}
|
2020-01-21 15:27:53 +00:00
|
|
|
|
|
|
|
return Registry::read(path, Registry::Global);
|
|
|
|
}();
|
|
|
|
|
|
|
|
return reg;
|
|
|
|
}
|
|
|
|
|
|
|
|
Registries getRegistries(ref<Store> store)
|
|
|
|
{
|
|
|
|
Registries registries;
|
2020-01-22 19:00:58 +00:00
|
|
|
registries.push_back(getFlagRegistry());
|
2020-01-21 15:27:53 +00:00
|
|
|
registries.push_back(getUserRegistry());
|
2020-04-01 20:56:50 +00:00
|
|
|
registries.push_back(getSystemRegistry());
|
2020-01-21 15:27:53 +00:00
|
|
|
registries.push_back(getGlobalRegistry(store));
|
|
|
|
return registries;
|
|
|
|
}
|
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
std::pair<Input, Attrs> lookupInRegistries(
|
2020-01-21 15:27:53 +00:00
|
|
|
ref<Store> store,
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
const Input & _input)
|
2020-01-21 15:27:53 +00:00
|
|
|
{
|
2020-03-17 19:54:36 +00:00
|
|
|
Attrs extraAttrs;
|
2020-01-21 15:27:53 +00:00
|
|
|
int n = 0;
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
Input input(_input);
|
2020-01-21 15:27:53 +00:00
|
|
|
|
|
|
|
restart:
|
|
|
|
|
|
|
|
n++;
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
if (n > 100) throw Error("cycle detected in flake registry for '%s'", input.to_string());
|
2020-01-21 15:27:53 +00:00
|
|
|
|
|
|
|
for (auto & registry : getRegistries(store)) {
|
|
|
|
// FIXME: O(n)
|
|
|
|
for (auto & entry : registry->entries) {
|
2020-04-01 21:12:45 +00:00
|
|
|
if (entry.exact) {
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
if (entry.from == input) {
|
2020-04-01 21:12:45 +00:00
|
|
|
input = entry.to;
|
|
|
|
extraAttrs = entry.extraAttrs;
|
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
} else {
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
if (entry.from.contains(input)) {
|
|
|
|
input = entry.to.applyOverrides(
|
|
|
|
!entry.from.getRef() && input.getRef() ? input.getRef() : std::optional<std::string>(),
|
|
|
|
!entry.from.getRev() && input.getRev() ? input.getRev() : std::optional<Hash>());
|
2020-04-01 21:12:45 +00:00
|
|
|
extraAttrs = entry.extraAttrs;
|
|
|
|
goto restart;
|
|
|
|
}
|
2020-01-21 15:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-29 22:44:11 +00:00
|
|
|
if (!input.isDirect())
|
|
|
|
throw Error("cannot find flake '%s' in the flake registries", input.to_string());
|
2020-01-21 15:27:53 +00:00
|
|
|
|
2020-02-20 21:14:44 +00:00
|
|
|
return {input, extraAttrs};
|
2020-01-21 15:27:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|