diff options
Diffstat (limited to 'src/libfetchers/path.cc')
-rw-r--r-- | src/libfetchers/path.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/libfetchers/path.cc b/src/libfetchers/path.cc index 01f1be978..11c952dc2 100644 --- a/src/libfetchers/path.cc +++ b/src/libfetchers/path.cc @@ -71,14 +71,28 @@ struct PathInputScheme : InputScheme return true; } - std::optional<Path> getSourcePath(const Input & input) override + std::optional<Path> getSourcePath(const Input & input) const override { return getStrAttr(input.attrs, "path"); } - void markChangedFile(const Input & input, std::string_view file, std::optional<std::string> commitMsg) override + void putFile( + const Input & input, + const CanonPath & path, + std::string_view contents, + std::optional<std::string> commitMsg) const override { - // nothing to do + writeFile((CanonPath(getAbsPath(input)) + path).abs(), contents); + } + + CanonPath getAbsPath(const Input & input) const + { + auto path = getStrAttr(input.attrs, "path"); + + if (path[0] == '/') + return CanonPath(path); + + throw Error("cannot fetch input '%s' because it uses a relative path", input.to_string()); } std::pair<StorePath, Input> fetch(ref<Store> store, const Input & _input) override |