aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/flake/lockfile.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/flake/lockfile.cc')
-rw-r--r--src/libexpr/flake/lockfile.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libexpr/flake/lockfile.cc b/src/libexpr/flake/lockfile.cc
index a7291db5b..b92ffb70e 100644
--- a/src/libexpr/flake/lockfile.cc
+++ b/src/libexpr/flake/lockfile.cc
@@ -1,5 +1,6 @@
#include "lockfile.hh"
#include "store-api.hh"
+#include "fetchers/regex.hh"
#include <nlohmann/json.hpp>
@@ -104,4 +105,20 @@ void LockFile::write(const Path & path) const
writeFile(path, fmt("%s\n", *this));
}
+InputPath parseInputPath(std::string_view s)
+{
+ InputPath path;
+
+ for (auto & elem : tokenizeString<std::vector<std::string>>(s, "/")) {
+ if (!std::regex_match(elem, fetchers::flakeIdRegex))
+ throw Error("invalid flake input path element '%s'", elem);
+ path.push_back(elem);
+ }
+
+ if (path.empty())
+ throw Error("flake input path is empty");
+
+ return path;
+}
+
}