summary refs log tree commit diff
path: root/doc
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2021-09-19 19:32:35 +0200
committerRobert Hensing <robert@roberthensing.nl>2021-09-19 19:33:18 +0200
commitf74b1608328b31c554b8c34b1036cf6c02210004 (patch)
tree3b86728f25302586f4bd4aef583e3b1098c61fee /doc
parent87b3740d66b369e4e447f3fcb58a657a268f213d (diff)
downloadnixpkgs-f74b1608328b31c554b8c34b1036cf6c02210004.tar
nixpkgs-f74b1608328b31c554b8c34b1036cf6c02210004.tar.gz
nixpkgs-f74b1608328b31c554b8c34b1036cf6c02210004.tar.bz2
nixpkgs-f74b1608328b31c554b8c34b1036cf6c02210004.tar.lz
nixpkgs-f74b1608328b31c554b8c34b1036cf6c02210004.tar.xz
nixpkgs-f74b1608328b31c554b8c34b1036cf6c02210004.tar.zst
nixpkgs-f74b1608328b31c554b8c34b1036cf6c02210004.zip
doc/builders/fetchers: Document FOD caveats
Diffstat (limited to 'doc')
-rw-r--r--doc/builders/fetchers.chapter.md14
1 files changed, 11 insertions, 3 deletions
diff --git a/doc/builders/fetchers.chapter.md b/doc/builders/fetchers.chapter.md
index 30d06534485..d54fe850c6c 100644
--- a/doc/builders/fetchers.chapter.md
+++ b/doc/builders/fetchers.chapter.md
@@ -1,8 +1,16 @@
 # Fetchers {#chap-pkgs-fetchers}
 
-When using Nix, you will frequently need to download source code and other files from the internet. Nixpkgs comes with a few helper functions that allow you to fetch fixed-output derivations in a structured way.
+When using Nix, you will frequently need to download source code and other files from the internet. For this purpose, Nix provides the [_fixed output derivation_](https://nixos.org/manual/nix/stable/#fixed-output-drvs) feature and Nixpkgs provides various functions that implement the actual fetching from various protocols and services.
 
-The two fetcher primitives are `fetchurl` and `fetchzip`. Both of these have two required arguments, a URL and a hash. The hash is typically `sha256`, although many more hash algorithms are supported. Nixpkgs contributors are currently recommended to use `sha256`. This hash will be used by Nix to identify your source. A typical usage of fetchurl is provided below.
+## Caveats
+
+Because fixed output derivations are _identified_ by their hash, a common mistake is to update a fetcher's URL or a version parameter, without updating the hash. **This will cause the old contents to be used.** So remember to always invalidate the hash argument.
+
+Similarly, a change to the implementation of a fetcher may cause a fixed output derivation to fail, but isn't caught by tests because the supposed output is already in the store or cache. So when testing a fetcher, always make sure to `nix-store --delete` the output and pay attention to the log, in case deletion was prevented by a garbage collection root.
+
+## `fetchurl` and `fetchzip` {#fetchurl}
+
+Two basic fetchers are `fetchurl` and `fetchzip`. Both of these have two required arguments, a URL and a hash. The hash is typically `sha256`, although many more hash algorithms are supported. Nixpkgs contributors are currently recommended to use `sha256`. This hash will be used by Nix to identify your source. A typical usage of fetchurl is provided below.
 
 ```nix
 { stdenv, fetchurl }:
@@ -20,7 +28,7 @@ The main difference between `fetchurl` and `fetchzip` is in how they store the c
 
 `fetchpatch` works very similarly to `fetchurl` with the same arguments expected. It expects patch files as a source and performs normalization on them before computing the checksum. For example it will remove comments or other unstable parts that are sometimes added by version control systems and can change over time.
 
-Other fetcher functions allow you to add source code directly from a VCS such as subversion or git. These are mostly straightforward nambes based on the name of the command used with the VCS system. Because they give you a working repository, they act most like `fetchzip`.
+Most other fetchers return a directory rather than a single file.
 
 ## `fetchsvn` {#fetchsvn}