2019-04-19 05:43:56 -04:00
|
|
|
#pragma once
|
|
|
|
|
2019-02-12 12:23:11 -05:00
|
|
|
#include "types.hh"
|
|
|
|
#include "hash.hh"
|
2020-01-31 13:16:40 -05:00
|
|
|
#include "fetchers/fetchers.hh"
|
2019-02-12 12:23:11 -05:00
|
|
|
|
|
|
|
#include <variant>
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
2020-01-21 10:27:53 -05:00
|
|
|
class Store;
|
2019-02-12 12:23:11 -05:00
|
|
|
|
|
|
|
typedef std::string FlakeId;
|
|
|
|
|
|
|
|
struct FlakeRef
|
|
|
|
{
|
2020-01-21 10:27:53 -05:00
|
|
|
std::shared_ptr<const fetchers::Input> input;
|
2019-02-12 12:23:11 -05:00
|
|
|
|
2020-01-21 10:27:53 -05:00
|
|
|
Path subdir;
|
2019-02-12 12:23:11 -05:00
|
|
|
|
2020-01-21 10:27:53 -05:00
|
|
|
bool operator==(const FlakeRef & other) const;
|
2019-04-08 13:03:00 -04:00
|
|
|
|
2020-01-21 10:27:53 -05:00
|
|
|
FlakeRef(const std::shared_ptr<const fetchers::Input> & input, const Path & subdir)
|
|
|
|
: input(input), subdir(subdir)
|
2019-04-08 13:03:00 -04:00
|
|
|
{
|
2020-01-21 10:27:53 -05:00
|
|
|
assert(input);
|
2019-04-08 13:03:00 -04:00
|
|
|
}
|
2019-02-21 00:53:01 -05:00
|
|
|
|
2019-02-12 12:23:11 -05:00
|
|
|
// FIXME: change to operator <<.
|
|
|
|
std::string to_string() const;
|
|
|
|
|
2020-03-17 15:54:36 -04:00
|
|
|
fetchers::Attrs toAttrs() const;
|
2020-01-31 13:16:40 -05:00
|
|
|
|
2020-01-21 10:27:53 -05:00
|
|
|
FlakeRef resolve(ref<Store> store) const;
|
2020-01-31 13:16:40 -05:00
|
|
|
|
2020-03-17 15:54:36 -04:00
|
|
|
static FlakeRef fromAttrs(const fetchers::Attrs & attrs);
|
2020-02-02 05:31:58 -05:00
|
|
|
|
|
|
|
std::pair<fetchers::Tree, FlakeRef> fetchTree(ref<Store> store) const;
|
2019-03-10 01:05:05 -05:00
|
|
|
};
|
2019-04-19 05:43:56 -04:00
|
|
|
|
|
|
|
std::ostream & operator << (std::ostream & str, const FlakeRef & flakeRef);
|
|
|
|
|
2020-01-21 10:27:53 -05:00
|
|
|
FlakeRef parseFlakeRef(
|
|
|
|
const std::string & url, const std::optional<Path> & baseDir = {});
|
|
|
|
|
|
|
|
std::optional<FlakeRef> maybeParseFlake(
|
|
|
|
const std::string & url, const std::optional<Path> & baseDir = {});
|
|
|
|
|
|
|
|
std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
|
|
|
|
const std::string & url, const std::optional<Path> & baseDir = {});
|
2019-05-31 14:53:23 -04:00
|
|
|
|
2020-01-21 10:27:53 -05:00
|
|
|
std::optional<std::pair<FlakeRef, std::string>> maybeParseFlakeRefWithFragment(
|
|
|
|
const std::string & url, const std::optional<Path> & baseDir = {});
|
2019-05-31 14:53:23 -04:00
|
|
|
|
2019-02-12 12:23:11 -05:00
|
|
|
}
|