2019-02-12 17:23:11 +00:00
|
|
|
#include "flakeref.hh"
|
2019-05-31 17:01:11 +00:00
|
|
|
#include "store-api.hh"
|
2020-03-30 12:03:28 +00:00
|
|
|
#include "url.hh"
|
|
|
|
#include "fetchers.hh"
|
|
|
|
#include "registry.hh"
|
2019-02-12 17:23:11 +00:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
#if 0
|
2019-05-01 18:23:39 +00:00
|
|
|
// 'dir' path elements cannot start with a '.'. We also reject
|
|
|
|
// potentially dangerous characters like ';'.
|
|
|
|
const static std::string subDirElemRegex = "(?:[a-zA-Z0-9_-]+[a-zA-Z0-9._-]*)";
|
|
|
|
const static std::string subDirRegex = subDirElemRegex + "(?:/" + subDirElemRegex + ")*";
|
2020-01-21 15:27:53 +00:00
|
|
|
#endif
|
2019-05-01 18:23:39 +00:00
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
std::string FlakeRef::to_string() const
|
2019-02-12 17:23:11 +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
|
|
|
auto url = input.toURL();
|
2020-03-28 17:05:50 +00:00
|
|
|
if (subdir != "")
|
|
|
|
url.query.insert_or_assign("dir", subdir);
|
|
|
|
return url.to_string();
|
2020-01-21 15:27:53 +00:00
|
|
|
}
|
2019-02-12 17:23:11 +00:00
|
|
|
|
2020-03-17 19:54:36 +00:00
|
|
|
fetchers::Attrs FlakeRef::toAttrs() const
|
2020-01-31 18:16:40 +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
|
|
|
auto attrs = input.toAttrs();
|
2020-01-31 18:16:40 +00:00
|
|
|
if (subdir != "")
|
2020-02-20 22:44:06 +00:00
|
|
|
attrs.emplace("dir", subdir);
|
2020-01-31 18:16:40 +00:00
|
|
|
return attrs;
|
|
|
|
}
|
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
std::ostream & operator << (std::ostream & str, const FlakeRef & flakeRef)
|
|
|
|
{
|
|
|
|
str << flakeRef.to_string();
|
|
|
|
return str;
|
|
|
|
}
|
2019-05-31 17:01:11 +00:00
|
|
|
|
2020-01-31 18:16:40 +00:00
|
|
|
bool FlakeRef::operator ==(const FlakeRef & other) const
|
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
|
|
|
return input == other.input && subdir == other.subdir;
|
2020-01-21 15:27:53 +00:00
|
|
|
}
|
2019-05-31 17:01:11 +00:00
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
FlakeRef FlakeRef::resolve(ref<Store> store) const
|
|
|
|
{
|
2020-02-20 21:14:44 +00:00
|
|
|
auto [input2, extraAttrs] = lookupInRegistries(store, input);
|
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
|
|
|
return FlakeRef(std::move(input2), fetchers::maybeGetStrAttr(extraAttrs, "dir").value_or(subdir));
|
2020-01-21 15:27:53 +00:00
|
|
|
}
|
2019-05-31 17:01:11 +00:00
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
FlakeRef parseFlakeRef(
|
2020-04-27 20:53:11 +00:00
|
|
|
const std::string & url, const std::optional<Path> & baseDir, bool allowMissing)
|
2020-01-21 15:27:53 +00:00
|
|
|
{
|
2020-04-27 20:53:11 +00:00
|
|
|
auto [flakeRef, fragment] = parseFlakeRefWithFragment(url, baseDir, allowMissing);
|
2020-01-21 15:27:53 +00:00
|
|
|
if (fragment != "")
|
|
|
|
throw Error("unexpected fragment '%s' in flake reference '%s'", fragment, url);
|
|
|
|
return flakeRef;
|
|
|
|
}
|
2019-02-12 17:23:11 +00:00
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
std::optional<FlakeRef> maybeParseFlakeRef(
|
|
|
|
const std::string & url, const std::optional<Path> & baseDir)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
return parseFlakeRef(url, baseDir);
|
|
|
|
} catch (Error &) {
|
|
|
|
return {};
|
2019-02-12 17:23:11 +00:00
|
|
|
}
|
2020-01-21 15:27:53 +00:00
|
|
|
}
|
2019-02-12 17:23:11 +00:00
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
|
2020-04-27 20:53:11 +00:00
|
|
|
const std::string & url, const std::optional<Path> & baseDir, bool allowMissing)
|
2020-01-21 15:27:53 +00:00
|
|
|
{
|
|
|
|
using namespace fetchers;
|
2019-02-12 17:23:11 +00:00
|
|
|
|
2020-02-03 14:27:26 +00:00
|
|
|
static std::string fnRegex = "[0-9a-zA-Z-._~!$&'\"()*+,;=]+";
|
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
static std::regex pathUrlRegex(
|
2020-02-03 14:27:26 +00:00
|
|
|
"(/?" + fnRegex + "(?:/" + fnRegex + ")*/?)"
|
2020-01-21 15:27:53 +00:00
|
|
|
+ "(?:\\?(" + queryRegex + "))?"
|
|
|
|
+ "(?:#(" + queryRegex + "))?",
|
|
|
|
std::regex::ECMAScript);
|
2019-04-08 20:46:25 +00:00
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
static std::regex flakeRegex(
|
Respect lock files of inputs + fine-grained lock file control
When computing a lock file, we now respect the lock files of flake
inputs. This is important for usability / reproducibility. For
example, the 'nixops' flake depends on the 'nixops-aws' and
'nixops-hetzner' repositories. So when the 'nixops' flake is used in
another flake, we want the versions of 'nixops-aws' and
'nixops-hetzner' locked by the the 'nixops' flake because those
presumably have been tested.
This can lead to a proliferation of versions of flakes like 'nixpkgs'
(since every flake's lock file could depend on a different version of
'nixpkgs'). This is not a major issue when using Nixpkgs overlays or
NixOS modules, since then the top-level flake composes those
overlays/modules into *its* version of Nixpkgs and all other versions
are ignored. Lock file computation has been made a bit more lazy so it
won't try to fetch all those versions of 'nixpkgs'.
However, in case it's necessary to minimize flake versions, there now
are two input attributes that allow this. First, you can copy an input
from another flake, as follows:
inputs.nixpkgs.follows = "dwarffs/nixpkgs";
This states that the calling flake's 'nixpkgs' input shall be the same
as the 'nixpkgs' input of the 'dwarffs' input.
Second, you can override inputs of inputs:
inputs.nixpkgs.url = github:edolstra/nixpkgs/<hash>;
inputs.nixops.inputs.nixpkgs.url = github:edolstra/nixpkgs/<hash>;
or equivalently, using 'follows':
inputs.nixpkgs.url = github:edolstra/nixpkgs/<hash>;
inputs.nixops.inputs.nixpkgs.follows = "nixpkgs";
This states that the 'nixpkgs' input of the 'nixops' input shall be
the same as the calling flake's 'nixpkgs' input.
Finally, at '-v' Nix now prints the changes to the lock file, e.g.
$ nix flake update ~/Misc/eelco-configurations/hagbard
inputs of flake 'git+file:///home/eelco/Misc/eelco-configurations?subdir=hagbard' changed:
updated 'nixpkgs': 'github:edolstra/nixpkgs/7845bf5f4b3013df1cf036e9c9c3a55a30331db9' -> 'github:edolstra/nixpkgs/03f3def66a104a221aac8b751eeb7075374848fd'
removed 'nixops'
removed 'nixops/nixops-aws'
removed 'nixops/nixops-hetzner'
removed 'nixops/nixpkgs'
2020-01-24 21:05:11 +00:00
|
|
|
"((" + flakeIdRegexS + ")(?:/(?:" + refAndOrRevRegex + "))?)"
|
2020-01-21 15:27:53 +00:00
|
|
|
+ "(?:#(" + queryRegex + "))?",
|
|
|
|
std::regex::ECMAScript);
|
2019-02-12 17:23:11 +00:00
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
std::smatch match;
|
2019-05-07 21:06:15 +00:00
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
/* Check if 'url' is a flake ID. This is an abbreviated syntax for
|
|
|
|
'flake:<flake-id>?ref=<ref>&rev=<rev>'. */
|
|
|
|
|
|
|
|
if (std::regex_match(url, match, flakeRegex)) {
|
|
|
|
auto parsedURL = ParsedURL{
|
|
|
|
.url = url,
|
|
|
|
.base = "flake:" + std::string(match[1]),
|
|
|
|
.scheme = "flake",
|
|
|
|
.authority = "",
|
|
|
|
.path = match[1],
|
2019-05-07 21:06:15 +00:00
|
|
|
};
|
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
return std::make_pair(
|
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
|
|
|
FlakeRef(Input::fromURL(parsedURL), ""),
|
2020-02-02 15:02:54 +00:00
|
|
|
percentDecode(std::string(match[6])));
|
2019-05-07 21:06:15 +00:00
|
|
|
}
|
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
else if (std::regex_match(url, match, pathUrlRegex)) {
|
|
|
|
std::string path = match[1];
|
2020-07-17 12:54:21 +00:00
|
|
|
std::string fragment = percentDecode(std::string(match[3]));
|
|
|
|
|
|
|
|
if (baseDir) {
|
|
|
|
/* Check if 'url' is a path (either absolute or relative
|
|
|
|
to 'baseDir'). If so, search upward to the root of the
|
|
|
|
repo (i.e. the directory containing .git). */
|
|
|
|
|
|
|
|
path = absPath(path, baseDir, true);
|
|
|
|
|
|
|
|
if (!S_ISDIR(lstat(path).st_mode))
|
|
|
|
throw BadURL("path '%s' is not a flake (because it's not a directory)", path);
|
|
|
|
|
|
|
|
if (!allowMissing && !pathExists(path + "/flake.nix"))
|
|
|
|
throw BadURL("path '%s' is not a flake (because it doesn't contain a 'flake.nix' file)", path);
|
2020-04-27 20:53:11 +00:00
|
|
|
|
2020-07-17 12:54:21 +00:00
|
|
|
auto flakeRoot = path;
|
|
|
|
std::string subdir;
|
|
|
|
|
|
|
|
while (flakeRoot != "/") {
|
|
|
|
if (pathExists(flakeRoot + "/.git")) {
|
|
|
|
auto base = std::string("git+file://") + flakeRoot;
|
|
|
|
|
|
|
|
auto parsedURL = ParsedURL{
|
|
|
|
.url = base, // FIXME
|
|
|
|
.base = base,
|
|
|
|
.scheme = "git+file",
|
|
|
|
.authority = "",
|
|
|
|
.path = flakeRoot,
|
|
|
|
.query = decodeQuery(match[2]),
|
|
|
|
};
|
|
|
|
|
|
|
|
if (subdir != "") {
|
|
|
|
if (parsedURL.query.count("dir"))
|
|
|
|
throw Error("flake URL '%s' has an inconsistent 'dir' parameter", url);
|
|
|
|
parsedURL.query.insert_or_assign("dir", subdir);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pathExists(flakeRoot + "/.git/shallow"))
|
|
|
|
parsedURL.query.insert_or_assign("shallow", "1");
|
|
|
|
|
|
|
|
return std::make_pair(
|
|
|
|
FlakeRef(Input::fromURL(parsedURL), get(parsedURL.query, "dir").value_or("")),
|
|
|
|
fragment);
|
|
|
|
}
|
2020-07-01 12:57:59 +00:00
|
|
|
|
2020-07-17 12:54:21 +00:00
|
|
|
subdir = std::string(baseNameOf(flakeRoot)) + (subdir.empty() ? "" : "/" + subdir);
|
|
|
|
flakeRoot = dirOf(flakeRoot);
|
2020-04-27 20:53:11 +00:00
|
|
|
}
|
|
|
|
|
2020-07-17 12:54:21 +00:00
|
|
|
} else {
|
|
|
|
if (!hasPrefix(path, "/"))
|
|
|
|
throw BadURL("flake reference '%s' is not an absolute path", url);
|
|
|
|
path = canonPath(path);
|
2020-01-21 15:27:53 +00:00
|
|
|
}
|
2019-02-12 17:23:11 +00:00
|
|
|
|
2020-04-27 20:53:11 +00:00
|
|
|
fetchers::Attrs attrs;
|
|
|
|
attrs.insert_or_assign("type", "path");
|
|
|
|
attrs.insert_or_assign("path", path);
|
2019-02-12 17:23:11 +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
|
|
|
return std::make_pair(FlakeRef(Input::fromAttrs(std::move(attrs)), ""), fragment);
|
2019-05-07 21:06:15 +00:00
|
|
|
}
|
2019-05-01 18:23:39 +00:00
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
else {
|
|
|
|
auto parsedURL = parseURL(url);
|
2020-02-02 15:02:54 +00:00
|
|
|
std::string fragment;
|
|
|
|
std::swap(fragment, parsedURL.fragment);
|
2020-01-21 15:27:53 +00:00
|
|
|
return std::make_pair(
|
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
|
|
|
FlakeRef(Input::fromURL(parsedURL), get(parsedURL.query, "dir").value_or("")),
|
2020-02-02 15:02:54 +00:00
|
|
|
fragment);
|
2020-01-21 15:27:53 +00:00
|
|
|
}
|
2019-09-18 21:59:45 +00:00
|
|
|
}
|
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
std::optional<std::pair<FlakeRef, std::string>> maybeParseFlakeRefWithFragment(
|
|
|
|
const std::string & url, const std::optional<Path> & baseDir)
|
2019-05-31 18:53:23 +00:00
|
|
|
{
|
|
|
|
try {
|
2020-01-21 15:27:53 +00:00
|
|
|
return parseFlakeRefWithFragment(url, baseDir);
|
|
|
|
} catch (Error & e) {
|
2019-05-31 18:53:23 +00:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-17 19:54:36 +00:00
|
|
|
FlakeRef FlakeRef::fromAttrs(const fetchers::Attrs & attrs)
|
2020-01-31 18:16:40 +00:00
|
|
|
{
|
|
|
|
auto attrs2(attrs);
|
2020-02-20 22:44:06 +00:00
|
|
|
attrs2.erase("dir");
|
2020-01-31 18:16:40 +00:00
|
|
|
return FlakeRef(
|
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
|
|
|
fetchers::Input::fromAttrs(std::move(attrs2)),
|
2020-02-20 22:44:06 +00:00
|
|
|
fetchers::maybeGetStrAttr(attrs, "dir").value_or(""));
|
2020-01-31 18:16:40 +00:00
|
|
|
}
|
|
|
|
|
2020-02-02 10:31:58 +00:00
|
|
|
std::pair<fetchers::Tree, FlakeRef> FlakeRef::fetchTree(ref<Store> store) const
|
|
|
|
{
|
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
|
|
|
auto [tree, lockedInput] = input.fetch(store);
|
|
|
|
return {std::move(tree), FlakeRef(std::move(lockedInput), subdir)};
|
2020-02-02 10:31:58 +00:00
|
|
|
}
|
|
|
|
|
2019-02-12 17:23:11 +00:00
|
|
|
}
|