diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2019-04-08 22:46:25 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2019-04-08 23:09:18 +0200 |
commit | 6a4c7fb9759dbbf5ddaf0ebd00921d0f8045f355 (patch) | |
tree | 13144d1669a7e3f361aa8df9dc8eaf4bf99a0e01 /src/libexpr/primops/flakeref.cc | |
parent | a9ceeeb4b0caf6891c8cd8fcbe744d3d567c1d8e (diff) |
Add path flakeref variant
Unlike file://<path>, this allows the path to be a dirty Git tree, so
nix build /path/to/flake:attr
is a convenient way to test building a local flake.
Diffstat (limited to 'src/libexpr/primops/flakeref.cc')
-rw-r--r-- | src/libexpr/primops/flakeref.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libexpr/primops/flakeref.cc b/src/libexpr/primops/flakeref.cc index 8e7c1f8df..5f9a29260 100644 --- a/src/libexpr/primops/flakeref.cc +++ b/src/libexpr/primops/flakeref.cc @@ -106,6 +106,12 @@ FlakeRef::FlakeRef(const std::string & uri) data = d; } + else if (hasPrefix(uri, "/")) { + IsPath d; + d.path = canonPath(uri); + data = d; + } + else throw Error("'%s' is not a valid flake reference", uri); } @@ -135,6 +141,10 @@ std::string FlakeRef::to_string() const (refData->rev ? "&rev=" + refData->rev->to_string(Base16, false) : ""); } + else if (auto refData = std::get_if<FlakeRef::IsPath>(&data)) { + return refData->path; + } + else abort(); } @@ -149,6 +159,9 @@ bool FlakeRef::isImmutable() const else if (auto refData = std::get_if<FlakeRef::IsGit>(&data)) return (bool) refData->rev; + else if (std::get_if<FlakeRef::IsPath>(&data)) + return false; + else abort(); } |