forked from lix-project/lix
Reword some comments/API docs to reflect libfetcher
's multiple users
It's not just flakes, but also `builtins.fetchTree`. Also try to provide some more info in general.
This commit is contained in:
parent
b912f3a937
commit
c816c67eed
|
@ -13,6 +13,12 @@
|
||||||
namespace nix::fetchers {
|
namespace nix::fetchers {
|
||||||
|
|
||||||
typedef std::variant<std::string, uint64_t, Explicit<bool>> Attr;
|
typedef std::variant<std::string, uint64_t, Explicit<bool>> Attr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An `Attrs` can be thought of a JSON object restricted or simplified
|
||||||
|
* to be "flat", not containing any subcontainers (arrays or objects)
|
||||||
|
* and also not containing any `null`s.
|
||||||
|
*/
|
||||||
typedef std::map<std::string, Attr> Attrs;
|
typedef std::map<std::string, Attr> Attrs;
|
||||||
|
|
||||||
Attrs jsonToAttrs(const nlohmann::json & json);
|
Attrs jsonToAttrs(const nlohmann::json & json);
|
||||||
|
|
|
@ -254,7 +254,8 @@ std::optional<Hash> Input::getRev() const
|
||||||
try {
|
try {
|
||||||
hash = Hash::parseAnyPrefixed(*s);
|
hash = Hash::parseAnyPrefixed(*s);
|
||||||
} catch (BadHash &e) {
|
} catch (BadHash &e) {
|
||||||
// Default to sha1 for backwards compatibility with existing flakes
|
// Default to sha1 for backwards compatibility with existing
|
||||||
|
// usages (e.g. `builtins.fetchTree` calls or flake inputs).
|
||||||
hash = Hash::parseAny(*s, htSHA1);
|
hash = Hash::parseAny(*s, htSHA1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,11 @@ struct Tree
|
||||||
struct InputScheme;
|
struct InputScheme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Input object is generated by a specific fetcher, based on the
|
* The `Input` object is generated by a specific fetcher, based on
|
||||||
* user-supplied input attribute in the flake.nix file, and contains
|
* user-supplied information, and contains
|
||||||
* the information that the specific fetcher needs to perform the
|
* the information that the specific fetcher needs to perform the
|
||||||
* actual fetch. The Input object is most commonly created via the
|
* actual fetch. The Input object is most commonly created via the
|
||||||
* "fromURL()" or "fromAttrs()" static functions which are provided
|
* `fromURL()` or `fromAttrs()` static functions.
|
||||||
* the url or attrset specified in the flake file.
|
|
||||||
*/
|
*/
|
||||||
struct Input
|
struct Input
|
||||||
{
|
{
|
||||||
|
@ -44,10 +43,20 @@ struct Input
|
||||||
std::optional<Path> parent;
|
std::optional<Path> parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Create an `Input` from a URL.
|
||||||
|
*
|
||||||
|
* The URL indicate which sort of fetcher, and provides information to that fetcher.
|
||||||
|
*/
|
||||||
static Input fromURL(const std::string & url, bool requireTree = true);
|
static Input fromURL(const std::string & url, bool requireTree = true);
|
||||||
|
|
||||||
static Input fromURL(const ParsedURL & url, bool requireTree = true);
|
static Input fromURL(const ParsedURL & url, bool requireTree = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an `Input` from a an `Attrs`.
|
||||||
|
*
|
||||||
|
* The URL indicate which sort of fetcher, and provides information to that fetcher.
|
||||||
|
*/
|
||||||
static Input fromAttrs(Attrs && attrs);
|
static Input fromAttrs(Attrs && attrs);
|
||||||
|
|
||||||
ParsedURL toURL() const;
|
ParsedURL toURL() const;
|
||||||
|
@ -116,13 +125,13 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The InputScheme represents a type of fetcher. Each fetcher
|
* The `InputScheme` represents a type of fetcher. Each fetcher
|
||||||
* registers with nix at startup time. When processing an input for a
|
* registers with nix at startup time. When processing an `Input`,
|
||||||
* flake, each scheme is given an opportunity to "recognize" that
|
* each scheme is given an opportunity to "recognize" that
|
||||||
* input from the url or attributes in the flake file's specification
|
* input from the user-provided url or attributes
|
||||||
* and return an Input object to represent the input if it is
|
* and return an `Input` object to represent the input if it is
|
||||||
* recognized. The Input object contains the information the fetcher
|
* recognized. The `Input` object contains the information the fetcher
|
||||||
* needs to actually perform the "fetch()" when called.
|
* needs to actually perform the `fetch()` when called.
|
||||||
*/
|
*/
|
||||||
struct InputScheme
|
struct InputScheme
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue