-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read file type #7447
Read file type #7447
Conversation
As a note to @roberth it looks like on Linux With that in mind the changes to Benchmarking is TODO. |
This should probably be changed into a |
I agree, except How about |
|
@aakropotkin I think the advantage of this "reduced stat" is that it returns just the attributes we care about in the store's model of the file system. |
I think Changing it to include any extra information would be a more significant change to the language, that would be less coherent with the # completing the current interface
pathType f
= (readDir (dirOf f)).${baseNameOf f}
= "file" or ...
# a possible future interface
pathInfo f
= (directoryNodes (dirOf f)).${baseNameOf f}
= { type = "file"; executable; size; }
or { type = "directory"; }
or ... I don't think we have a feature request for the latter (except an outlier optimization bug that @aakropotkin subtly referenced here, that we should probably fix in some other way) whereas we do for I suggest we complete the current interface, which does not interfere with the possible future interface, thereby achieving the goals in the simplest way. This way we avoid having to answer questions that we really don't need to answer, such as whether the extra attrsets impact performance, which attributes should even be in there, etc. (+ discussions, extra review rounds that we can better spend on the larger issues) There is a time for |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2022-12-12-nixpkgs-architecture-team-meeting-21/23967/1 |
I'm on board with @roberth aside from the function name. I'd personally have a lot of use cases for I'll take another pass at the notes we have here and update the PR. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2022-12-19-nixpkgs-architecture-team-meeting-22/24125/1 |
Field testing a PR checklist (#7538), because I messed up. Apologies for not doing this sooner. The Nix team is improving.
|
Discussed in Nix team meeting 2022-12-23:
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2022-12-23-nix-team-meeting-minutes-19/24400/1 |
Discussed in Nix team meeting 2023-01-02:
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-01-02-nix-team-meeting-minutes-20/24403/1 |
Not saying we should do that (I think it is probably fine to just stabilize this) but I think we could make an "anonymous primop" that doesn't require a stable feature but also can't be accessed by user code. |
We definitely could, but we don't need to go there because we have a valid use case #3096 and we've discussed the design, deciding not to over-engineer and stick to the valid use case, as it is sufficient and coherent with the existing |
I agree. I just wanted to point that a middle ground does exist if others insisted -- not advocate for it! |
a06cad3
to
8b5d3f6
Compare
Allows checking directory entry type of a single file/directory. This was added to optimize the use of `builtins.readDir` on some filesystems and operating systems which cannot detect this information using POSIX's `readdir`. Previously `builtins.readDir` would eagerly use system calls to lookup these filetypes using other interfaces; this change makes these operations lazy in the attribute values for each file with application of `builtins.readFileType`.
8b5d3f6
to
153ee46
Compare
Merged 2.13.0, squashed, and ready to merge. |
Why was this renamed from I think We now have this situation:
Also there's already a I think this should really have been |
I think I was intentionally trying to avoid confusing "path type" ( the Nix construct ) with "filesystem path". I felt that In retrospect |
I wasn't super happy about the name, but we had already bikeshedded towards this and at least two people agreed on this name. I guess I have to be more annoying then. So
Good. I hope this is the final drop in the bucket and we actively start avoiding direct use of builtins. |
Could we backport this to the 2.13 release since that will be the default for NixOS 23.05 and because |
Is it? I thought the I do support a backport; I just don't understand the urgency. |
Successfully created backport PR for |
@roberth The more specific problem I ran into was this: {
outputs = { nixpkgs, ... }: {
test = nixpkgs.lib.pathType ./.;
};
}
This is caused because the old This is not specific to flakes though, pure evaluation of any |
And even more concretely, |
Adds a new primop
readFileType
, allowingreadDir
to create thunks for unknown types when reading large directories.