Skip to content
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

document fetchTree #9258

Merged
merged 6 commits into from
Dec 10, 2023
Merged

document fetchTree #9258

merged 6 commits into from
Dec 10, 2023

Conversation

fricklerhandwerk
Copy link
Contributor

@fricklerhandwerk fricklerhandwerk commented Oct 30, 2023

As discussed with @NixOS/nix-team.

Priorities

Add 👍 to pull requests you find important.


<!-- TODO: It would be soooo much more predictable to work with (and
document) if `fetchTree` was a curried call with the first paramter for
`type` or an attribute like `builtins.fetchTree.git`! -->
Copy link
Contributor

@tomberek tomberek Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very interesting, nested builtin to disambiguation the type. On the other hand, this makes the idempotency a little more awkward.

Copy link
Contributor

@tomberek tomberek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few fixups and TODOs, but this is in line with our last review session. Would be good to have a more discerning eye take a look (@infinisil , does this address your doctor concerns?)

@Ericson2314
Copy link
Member

This one is so big, I think it would be better to put in a separate file which is #included in.

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks so much better! Left some minor suggestions :)

src/libexpr/primops/fetchTree.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchTree.cc Show resolved Hide resolved
src/libexpr/primops/fetchTree.cc Outdated Show resolved Hide resolved
Comment on lines +354 to +372
> **Example**
>
> Fetch a GitHub repository using the attribute set representation:
>
> ```nix
> builtins.fetchTree {
> type = "github";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better not use something that's experimental as an example.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a good chance we'll stabilize these together, considering that possibly a majority of usages of fetchTree are with this type.

@edolstra
Copy link
Member

edolstra commented Nov 1, 2023

I'm not sure builtins.fetchTree is the best place to document this, especially since it now duplicates part of the "Types" section of the nix flakes page. Maybe we can have a separate page on fetchers and refer to that from both builtins.fetchTree and the nix flakes page?

@fricklerhandwerk
Copy link
Contributor Author

Maybe we can have a separate page on fetchers and refer to that from both builtins.fetchTree and the nix flake page?

Given we're carving out this particular builtin, everything specific to its behavior should be part of its documentation.

The nix flake page can link to that, ans is quite large already anyway. We just didn't get as far as moving the information from there to here yet.

@Ericson2314
Copy link
Member

We do want things deduplicated long term, yes. But for now the only release blocker is worrying about the docs for the newly stable things. Deduplicating with the Flakes docs is not a release blocker because it comes later.

That said, my automation can help with this.

@infinisil infinisil mentioned this pull request Nov 1, 2023
2 tasks
@edolstra
Copy link
Member

edolstra commented Nov 3, 2023

Given we're carving out this particular builtin, everything specific to its behavior should be part of its documentation.

That makes no sense. There are a lot of builtins whose behaviour is not fully explained by the builtin's docs, e.g. anything having to do with the Nix store. It seems very poor writing to duplicate information everywhere.

@infinisil
Copy link
Member

I agree with @edolstra that for reference docs, there shouldn't be duplication and a lot of linking seems preferable.

(though I'll take good docs with some duplication over bad docs any day of the week 🙂)

@fricklerhandwerk
Copy link
Contributor Author

I never said we should duplicate information, I simply didn't get to moving it around in this PR yet. Although that may become quite an effort altogether, so don't count on it getting merged yesterday.

src/libexpr/primops/fetchTree.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchTree.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchTree.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchTree.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchTree.cc Outdated Show resolved Hide resolved
Downloads are cached in `$XDG_CACHE_HOME/nix`.
The remote source will be fetched from the network if:
- The resulting store path is not [valid](@docroot@/glossary.md#gloss-validity)
- There is no cache entry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and or or?

src/libexpr/primops/fetchTree.cc Outdated Show resolved Hide resolved
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-11-03-nix-team-meeting-minutes-100/35245/1

fricklerhandwerk and others added 2 commits December 4, 2023 16:07
Co-authored-by: tomberek <tomberek@users.noreply.github.com>
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
we have to enable the new `fetchTree` experimental feature to render it
at all. this was a bug introduced when adding that new feature flag.
@fricklerhandwerk
Copy link
Contributor Author

Reworked together with @roberth. We decided to leave the documentation on the flakes man page as is, because it needs a more work to untangle. Also that page talks about flakerefs, which are more than just the fetchTree input attributes, so it's not really wrong to have that separate.

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking pretty good!

src/libexpr/primops/fetchTree.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchTree.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchTree.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchTree.cc Outdated Show resolved Hide resolved
Co-authored-by: Silvan Mosberger <github@infinisil.com>
Co-authored-by: Silvan Mosberger <github@infinisil.com>
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final fixups for now. This documentation is far from perfect, but it's the best we can do before overhauling it.

src/libexpr/primops/fetchTree.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchTree.cc Outdated Show resolved Hide resolved
@roberth
Copy link
Member

roberth commented Dec 10, 2023

Can't push to tweag. Please apply and auto-merge.

fricklerhandwerk and others added 2 commits December 10, 2023 05:55
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
@fricklerhandwerk fricklerhandwerk enabled auto-merge (squash) December 10, 2023 05:00
@fricklerhandwerk fricklerhandwerk merged commit 3c200da into NixOS:master Dec 10, 2023
8 checks passed
@DavHau
Copy link
Member

DavHau commented Dec 27, 2023

#9390 has been reverted by this PR accidentally I guess

DavHau added a commit to DavHau/nix that referenced this pull request Dec 27, 2023
@DavHau
Copy link
Member

DavHau commented Dec 27, 2023

#9390 has been reverted by this PR accidentally I guess

Sorry for the confusion. It hasn't been reverted.
But but now the git arguments are documented twice. One time in the fetchTree docs and another time in the fetchGit docs.

Both instances are incomplete and conflict each other. Few things I notice:

  • the description of shallow in fetchTree is wrong
  • some fields are missing from the fetchTree docs like: verifyCommit, publicKey, publicKeys, keytype
  • revCount is missing for fetchGit and it doesn't mention that the provided revCount will be checked against the computed revCount and that nix will fail if there is a mismatch. (TBH this feature seems useless, I'm not sure if it should be documented at all)

EDIT: Maybe it's worth considering deduplicating the docs. The docs of fetchGit could just point to fetchTree for the argument reference, or vice versa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation new-cli Relating to the "nix" command
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

8 participants