Skip to content

Commit

Permalink
Update fetchTree docs
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Sep 28, 2023
1 parent 7ce912b commit d2175fd
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/libexpr/primops/fetchTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ static RegisterPrimOp primop_fetchTree({
.args = {"input"},
.doc = R"(
Fetch a source tree or a plain file using one of the supported backends.
*input* can be an attribute set representation of [flake reference](@docroot@/command-ref/new-cli/nix3-flake.md#flake-references) or a URL.
The input should be "locked", that is, it should contain a commit hash or content hash unless impure evaluation (`--impure`) is allowed.
*input* must be a [flake reference](@docroot@/command-ref/new-cli/nix3-flake.md#flake-references), either in attribute set representation or in the URL-like syntax.
The input should be "locked", that is, it should contain a commit hash or content hash unless impure evaluation (`--impure`) is enabled.
Here are some examples of how to use `fetchTree`:
- Fetch a GitHub repository:
- Fetch a GitHub repository using the attribute set representation:
```nix
builtins.fetchTree {
Expand All @@ -191,7 +191,7 @@ static RegisterPrimOp primop_fetchTree({
}
```
This evaluates to attribute set:
This evaluates to the following attribute set:
```
{
Expand All @@ -203,15 +203,12 @@ static RegisterPrimOp primop_fetchTree({
shortRev = "ae2e6b3";
}
```
- Fetch a single file from a URL:
```nix
builtins.fetchTree "https://example.com/"
```
- Fetch the same GitHub repository using the URL-like syntax:
> **Note**
>
> This function requires the [`flakes` experimental feature](@docroot@/contributing/experimental-features.md#xp-feature-flakes) to be enabled.
```
builtins.fetchTree "github:NixOS/nixpkgs/ae2e6b3958682513d28f7d633734571fb18285dd"
```
)",
.fun = prim_fetchTree
});
Expand Down

0 comments on commit d2175fd

Please sign in to comment.