Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
flakeref.hh
Go to the documentation of this file.
1#pragma once
3
4#include <regex>
5#include <iosfwd>
6#include <string>
7#include <tuple>
8#include <utility>
9
12
13namespace nix {
14
15class Store;
16
17namespace fetchers {
18struct Settings;
19} // namespace fetchers
20
21typedef std::string FlakeId;
22
43struct FlakeRef
44{
50
56 std::string subdir;
57
58 bool operator==(const FlakeRef & other) const = default;
59
60 bool operator<(const FlakeRef & other) const
61 {
62 return std::tie(input, subdir) < std::tie(other.input, other.subdir);
63 }
64
65 FlakeRef(fetchers::Input && input, const std::string & subdir)
66 : input(std::move(input))
67 , subdir(subdir)
68 {
69 }
70
71 // FIXME: change to operator <<.
72 std::string to_string() const;
73
74 fetchers::Attrs toAttrs() const;
75
76 FlakeRef resolve(
77 const fetchers::Settings & fetchSettings,
78 Store & store,
79 fetchers::UseRegistries useRegistries = fetchers::UseRegistries::All) const;
80
81 static FlakeRef fromAttrs(const fetchers::Attrs & attrs);
82
83 std::pair<ref<SourceAccessor>, FlakeRef> lazyFetch(const fetchers::Settings & fetchSettings, Store & store) const;
84
89 FlakeRef canonicalize() const;
90};
91
92std::ostream & operator<<(std::ostream & str, const FlakeRef & flakeRef);
93
97FlakeRef parseFlakeRef(
98 std::string_view url,
99 const std::optional<std::filesystem::path> & baseDir = {},
100 bool allowMissing = false,
101 bool isFlake = true,
102 bool preserveRelativePaths = false);
103
107std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
108 std::string_view url,
109 const std::optional<std::filesystem::path> & baseDir = {},
110 bool allowMissing = false,
111 bool isFlake = true,
112 bool preserveRelativePaths = false);
113
117std::tuple<FlakeRef, std::string, ExtendedOutputsSpec> parseFlakeRefWithFragmentAndExtendedOutputsSpec(
118 std::string_view url,
119 const std::optional<std::filesystem::path> & baseDir = {},
120 bool allowMissing = false,
121 bool isFlake = true);
122
123static const std::string flakeIdRegexS = "[a-zA-Z][a-zA-Z0-9_-]*";
124extern std::regex flakeIdRegex;
125
126} // namespace nix
Definition store-api.hh:397
Definition flakeref.hh:44
FlakeRef canonicalize() const
Definition flakeref.cc:295
std::string subdir
Definition flakeref.hh:56
fetchers::Input input
Definition flakeref.hh:49
Definition fetchers.hh:36
Definition fetch-settings.hh:27