-
-
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
Poor fetchTree
documentation
#9249
Comments
Thank you for this exhaustive look over the docs, @infinisil. I would add we really shouldn't be stabilizing anything at all until it is properly documented (and tested); that would constitute a regression in our quality (and test coverage). I think this situation needs to be fixed by the Nix release (when it could actually become stable), or else I understand this might feel like a hoop to jump through for those that think that the real benefit is Flakes, |
Because we have the pluggable fetchers arch, I would expect that incorporating it into the CLI dump the way we do with builtins, flags, etc. might be the right way to go. Ideally we can make some of reference docs of individual fields etc. more automated and easy to keep up to date that way. |
In any case, I'll soon start working on the docs as promised so we have something written down at all. @infinisil thanks a lot for the compilation. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-10-27-nix-team-meeting-minutes-98/34695/1 |
This PR improves the docs: #9258 |
I've made an attempt to make sense of how the fetchers and flakes features interact. flowchart TD
classDef process fill:#9f6
classDef world fill:#f7f7f7,stroke:none
world([world]):::world
ref([source ref])
lock([lock])
%% e.g. revCount
metadata([metadata])
%% things like git tree hash if you already have a commit hash.
%% cacheable things that may speed up the fetch
optional([optional lock attrs])
contents([store contents])
ref--> locking
world --> locking
world([the world])
locking:::process --> lock
locking --> metadata
locking -.-> cache
locking -.-> optional
flake[call-flake]:::process
cache([cache])
cache --> fetchToStore
lock --> flake
metadata --> flake
optional -.-> fetchToStore
outPath([outPath])
sourceInfo([sourceInfo])
flake --> sourceInfo
lock --> fetchToStore:::process
world --> fetchToStore
fetchToStore --> contents
fetchToStore --> outPath
strip[strip]
strip:::process --> ref
flakeref([flakeref])
flakeref --> strip
outPath --> flake
subgraph fetchers
cache
locking
fetchToStore
metadata
lock
optional
end
|
I consider this mostly addressed now that #9258 is merged |
Problem
Now that
fetchTree
has been partially stabilised, I wanted to check the docs to see what is supported, but the docs turn out to be very poor:The entry point
builtins.fetchTree
only has this sentence on what argument it takes:The
fetchTree
stabilisation PR further adds to this that the URL-syntax requires flakes to be enabled, okay so only the attribute set representation is supported.So going to the flake references documentation, the attribute set syntax is documented as follows:
The rest of the document just documents the URL-syntax!
Furthermore, the Types section (which is quite a bunch further down and isn't linked to) really doesn't clear things up:
For one, the
path
type is not yet stable, but it's not even mentioned here (or anywhere else for that matter). Furthermore, it's really unclear what the attribute set syntax is supposed to be for this type..Let's check out the now-stable
git
type:Immediate questions that aren't answered even reading further:
server
,path
,params
a supported attribute?url
relate to this long line? I guess probably everything after the (optional)+
could be the URLgit+git
supposed to be? And generally what do all of these+
syntax do? There's only an explanation forgit+file
+
syntax with an attribute set?type = "git+path"
doesn't seem to workFurthermore, the section on flake reference attributes doesn't help:
dir
is a generic attribute supported by all types, but if you read one sentence of it, it's doing something specific to aflake.nix
. And trying it out it doesn't work..narHash
is a generic one, but trying it out, it seems to change the output attributes!More generally, it's not documented what
builtins.fetchTree
even returns! The only clue we have is an example in the builtin docs, but the above shows that it's not generalReading further in the flake reference attribute section:
It then lists
revCount
andlastModified
, but it's unclear what "available to Nix code means". From the above evaluation these seem to be output attributes, or does "available" also mean they can be specified in the input?Yup that seems to work, I can specify
revCount
and it just seems to get passed through without checking, the revCount is actually wrong here. What if I don't pass thenarHash
anymore?Oh only then it complains about it being wrong. What about
shortRev
though? That was there in the output without anarHash
, was that just not documented but it works the same asrevCount
?No that is not supported at all in the input.
So in conclusion, the docs for
fetchTree
really suck.Proposal
Clean up this mess before calling
fetchTree
stable. I have really no clue what exactly is really supposed to be stable now.Checklist
Priorities
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: