Home Explore Blog CI



nixpkgs

5th chunk of `doc/build-helpers/fetchers.chapter.md`
a657749139b3a68f745b2a439e4b683c478e08aba46c87ec0000000100000fbe
  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` Inputs: Hashing Algorithms, Naming, and Execution
Summary
This section continues detailing input attributes for the `fetchurl` function. It covers `sha512`, the SHA-512 hash of the output, along with attributes that determine the name of the downloaded file in the Nix store: `name`, `pname`, and `version`. Furthermore, it describes `recursiveHash`, `executable`, `downloadToTemp`, and `postFetch`, controlling aspects like recursive hashing, executable bit setting, temporary download locations, and post-download script execution.