Home Explore Blog Models CI



nixpkgs

5th chunk of `doc/build-helpers/fetchers.chapter.md`
6c467d923d422d5e575578dcf327109ba434275fb6507dbf0000000100000fbe
  See [the documentation on the Nix manual](https://nixos.org/manual/nix/stable/language/advanced-attributes.html#adv-attr-outputHashAlgo) for more information about the values it supports.

  :::{.note}
  It is recommended that you use the `hash` attribute instead.

  The value specified in `outputHashAlgo` will be ignored if `outputHash` isn't also specified.
  :::

  _Default value:_ `""`.

`sha1` (String; _optional_)
: SHA-1 hash of the derivation output of `fetchurl` in the format expected by Nix.
  See [the documentation on the Nix manual](https://nixos.org/manual/nix/stable/language/advanced-attributes.html#adv-attr-outputHash) for more information about its format.

  :::{.note}
  It is recommended that you use the `hash` attribute instead.
  :::

  _Default value:_ `""`.

`sha256` (String; _optional_)
: SHA-256 hash of the derivation output of `fetchurl` in the format expected by Nix.
  See [the documentation on the Nix manual](https://nixos.org/manual/nix/stable/language/advanced-attributes.html#adv-attr-outputHash) for more information about its format.

  :::{.note}
  It is recommended that you use the `hash` attribute instead.
  :::

  _Default value:_ `""`.

`sha512` (String; _optional_)
: SHA-512 hash of the derivation output of `fetchurl` in the format expected by Nix.
  See [the documentation on the Nix manual](https://nixos.org/manual/nix/stable/language/advanced-attributes.html#adv-attr-outputHash) for more information about its format.

  :::{.note}
  It is recommended that you use the `hash` attribute instead.
  :::

  _Default value:_ `""`.

`name` (String; _optional_)
: The symbolic name of the downloaded file when saved in the Nix store.
  See [the `fetchurl` overview](#sec-pkgs-fetchers-fetchurl) for details on how the name of the file is decided.

  _Default value:_ `""`.

`pname` (String; _optional_)
: A base name, which will be combined with `version` to form the symbolic name of the downloaded file when saved in the Nix store.
  See [the `fetchurl` overview](#sec-pkgs-fetchers-fetchurl) for details on how the name of the file is decided.

  :::{.note}
  If `pname` is specified, you must also specify `version`, otherwise `fetchurl` will ignore the value of `pname`.
  :::

  _Default value:_ `""`.

`version` (String; _optional_)
: A version, which will be combined with `pname` to form the symbolic name of the downloaded file when saved in the Nix store.
  See [the `fetchurl` overview](#sec-pkgs-fetchers-fetchurl) for details on how the name of the file is decided.

  _Default value:_ `""`.

`recursiveHash` (Boolean; _optional_) []{#sec-pkgs-fetchers-fetchurl-inputs-recursiveHash}
: If set to `true`, will signal to Nix that the hash given to `fetchurl` was calculated using the `"recursive"` mode.
  See [the documentation on the Nix manual](https://nixos.org/manual/nix/stable/language/advanced-attributes.html#adv-attr-outputHashMode) for more information about the existing modes.

  By default, `fetchurl` uses `"recursive"` mode when the `executable` attribute is set to `true`, so you don't need to specify `recursiveHash` in this case.

  _Default value:_ `false`.

`executable` (Boolean; _optional_)
: If `true`, sets the executable bit on the downloaded file.

  _Default value_: `false`.

`downloadToTemp` (Boolean; _optional_) []{#sec-pkgs-fetchers-fetchurl-inputs-downloadToTemp}
: If `true`, saves the downloaded file to a temporary location instead of the expected Nix store location.
  This is useful when used in conjunction with `postFetch` attribute, otherwise `fetchurl` will not produce any meaningful output.

  The location of the downloaded file will be set in the `$downloadedFile` variable, which should be used by the script in the `postFetch` attribute.
  See [](#ex-fetchers-fetchurl-nixpkgs-version-postfetch) to understand how to work with this attribute.

  _Default value:_ `false`.

`postFetch` (String; _optional_)
: Script executed after the file has been downloaded successfully, and before `fetchurl` finishes running.

Title: `fetchurl` Input Attributes: Hashing, Naming, and Download Behavior
Summary
This section describes optional `fetchurl` attributes, covering hash specifications, file naming, and advanced download behaviors. For hashing, `sha1`, `sha256`, and `sha512` are backwards-compatible (prefer `hash` attribute). `outputHashAlgo` specifies the `outputHash` algorithm, ignored if `outputHash` isn't set. For naming, `name` provides a direct symbolic name. Alternatively, `pname` and `version` combine (e.g., `pname-version`), but `pname` requires `version`. Behavioral attributes: `recursiveHash` signals recursive hash mode (defaults `true` if `executable` is `true`); `executable` sets the executable bit; `downloadToTemp` saves to temp (useful with `postFetch`, exposes path in `$downloadedFile`). `postFetch` is a script run after download, before `fetchurl` finishes.