New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backport SourcePath
from the lazy-trees branch
#8172
Conversation
This introduces the SourcePath type from lazy-trees as an abstraction for accessing files from inputs that may not be materialized in the real filesystem (e.g. Git repositories). Currently, however, it's just a wrapper around CanonPath, so it shouldn't change any behaviour. (On lazy-trees, SourcePath is a <InputAccessor, CanonPath> tuple.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review.
Mostly questions to be addressed by doc comments.
/** | ||
* Copy this `SourcePath` to the Nix store. | ||
*/ | ||
StorePath fetchToStore( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd call this addToStore
. Fetching only makes sense for some StorePath
s, and currently none.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addToStore
is already pretty overloaded. fetchToStore
makes clear that this involves libfetcher.
std::string to_string() const | ||
{ return path.abs(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of the string?
What's the syntax of the returned string?
Does it need to be deterministic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the lazy-trees branch, it represents a human-readable representation of the path, such as 芦github:NixOS/nixpkgs/bla:foo/bar.nix禄
, intended in error messages etc. So it doesn't need to be deterministic, but it currently is.
|
||
/** | ||
* Return the location of this path in the "real" filesystem, if | ||
* it has a physical location. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All source paths can be given a physical location.
What are valid reasons not to return one?
Should this guarantee accurate file contents at that path?
What are valid use cases for this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, all source paths can be written to the filesystem, but for some fetchers this could be expensive. If the caller needs a physical path they can use fetchToStore()
.
This is currently used for nix-instantiate --find-file
, nix edit
and nix develop
(where we can't chdir
into a flake that doesn't exist in the filesystem).
SourcePath
from the lazy-trees branch
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-04-17-nix-team-meeting-minutes-49/27379/1 |
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This causes a regression where |
Motivation
This introduces the
SourcePath
type from lazy-trees as an abstraction for accessing files from inputs that may not be materialized in the real filesystem (e.g. Git repositories). Currently, however, it's just a wrapper aroundCanonPath
, so it shouldn't change any behaviour. (On lazy-trees,SourcePath
is a<InputAccessor, CanonPath>
tuple.)The reason for this PR is to make the
lazy-trees
diff smaller and make it easier to keep that branch in sync.Context
Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
tests/**.sh
src/*/tests
tests/nixos/*
Priorities
Add 馃憤 to pull requests you find important.