Deduplicate listNar and MemorySourceAccessor::File#14598
Merged
Ericson2314 merged 4 commits intomasterfrom Nov 20, 2025
Merged
Conversation
xokdvium
requested changes
Nov 20, 2025
Contributor
xokdvium
left a comment
There was a problem hiding this comment.
There seems to be some tricky changes to the serialisation logic around handling of nullopt values. Looks like a pretty big footgun if we are not very careful. A missing key is very different from zero value.
Under which circumstances can st.narOffset and st.fileSize can be nullopt even?
Contributor
|
My comments might turn out inconsequential, but that seems like a slight behavior change. Not sure whether it matters in practice though. Just want to better understand what's going on there |
This matches the "NAR Listing" JSON format, and also helps distinguish from regular file contents. Why we want to match that will become clear in the next comments, when we will in fact use (variations of) this data type for NAR listings.
File-system-object-layer functionality doesn't depend on store-layer concets, and therefore doesn't need to live inside there.
A shared pointer is not needed.
`listNar` did the not-so-pretty thing of going straight to JSON. Now it uses `MemorySourceAccessor::File`, or rather variations of it, to go to a C++ data type first, and only JSON second. To accomplish this we add some type parameters to the `File` data type. Actually, we need to do two rounds of this, because shallow NAR listings. There is `FileT` and `DirectoryT` accordingly.
282fae6 to
c490674
Compare
xokdvium
approved these changes
Nov 20, 2025
Contributor
xokdvium
left a comment
There was a problem hiding this comment.
Seems equivalent to me now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
listNardid the not-so-pretty thing of going straight to JSON. Now it usesMemorySourceAccessor::File, or rather variations of it, to go to a C++ data type first, and only JSON second.Context
To accomplish this we add some type parameters to the
Filedata type. Actually, we need to do two rounds of this, because shallow NAR listings. There isFileTandDirectoryTaccordingly.The above descriptions are from the last commit, before that I have some tiny cleanups which should be self-explanatory. Review commit-by-commit to get better diffs.
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.