···283283284284 _Default value:_ `""`.
285285286286-`recursiveHash` (Boolean; _optional_)
286286+`recursiveHash` (Boolean; _optional_) []{#sec-pkgs-fetchers-fetchurl-inputs-recursiveHash}
287287: If set to `true`, will signal to Nix that the hash given to `fetchurl` was calculated using the `"recursive"` mode.
288288 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.
289289···296296297297 _Default value_: `false`.
298298299299-`downloadToTemp` (Boolean; _optional_)
299299+`downloadToTemp` (Boolean; _optional_) []{#sec-pkgs-fetchers-fetchurl-inputs-downloadToTemp}
300300: If `true`, saves the downloaded file to a temporary location instead of the expected Nix store location.
301301 This is useful when used in conjunction with `postFetch` attribute, otherwise `fetchurl` will not produce any meaningful output.
302302···519519520520## `fetchzip` {#sec-pkgs-fetchers-fetchzip}
521521522522-Downloads content from a given URL (which is assumed to be an archive), and decompresses the archive for you, making files and directories directly accessible.
523523-`fetchzip` can only be used with archives.
524524-Despite its name, `fetchzip` is not limited to `.zip` files and can also be used with any tarball.
522522+Returns a [fixed-output derivation](https://nixos.org/manual/nix/stable/glossary.html#gloss-fixed-output-derivation) which downloads an archive from a given URL and decompresses it.
523523+524524+Despite its name, `fetchzip` is not limited to `.zip` files but can also be used with [various compressed tarball formats](#tar-files) by default.
525525+This can extended by specifying additional attributes, see [](#ex-fetchers-fetchzip-rar-archive) to understand how to do that.
526526+527527+### Inputs {#sec-pkgs-fetchers-fetchzip-inputs}
528528+529529+`fetchzip` requires an attribute set, and most attributes are passed to the underlying call to [`fetchurl`](#sec-pkgs-fetchers-fetchurl).
530530+531531+The attributes below are treated differently by `fetchzip` when compared to what `fetchurl` expects:
532532+533533+`name` (String; _optional_)
534534+: Works as defined in `fetchurl`, but has a different default value than `fetchurl`.
535535+536536+ _Default value:_ `"source"`.
537537+538538+`nativeBuildInputs` (List of Attribute Set; _optional_)
539539+: Works as defined in `fetchurl`, but it is also augmented by `fetchzip` to include packages to deal with additional archives (such as `.zip`).
540540+541541+ _Default value:_ `[]`.
542542+543543+`postFetch` (String; _optional_)
544544+: Works as defined in `fetchurl`, but it is also augmented with the code needed to make `fetchzip` work.
545545+546546+ :::{.caution}
547547+ It is only safe to modify files in `$out` in `postFetch`.
548548+ Consult the implementation of `fetchzip` for anything more involved.
549549+ :::
525550526526-It has two required arguments, a URL and a hash.
527527-The hash is typically `hash`, although many more hash algorithms are supported.
528528-Nixpkgs contributors are currently recommended to use `hash`.
529529-This hash will be used by Nix to identify your source.
530530-A typical usage of `fetchzip` is provided below.
551551+ _Default value:_ `""`.
552552+553553+`stripRoot` (Boolean; _optional_)
554554+: If `true`, the decompressed contents are moved one level up the directory tree.
555555+556556+ This is useful for archives that decompress into a single directory which commonly includes some values that change with time, such as version numbers.
557557+ When this is the case (and `stripRoot` is `true`), `fetchzip` will remove this directory and make the decompressed contents available in the top-level directory.
558558+559559+ [](#ex-fetchers-fetchzip-simple-striproot) shows what this attribute does.
560560+561561+ This attribute is **not** passed through to `fetchurl`.
562562+563563+ _Default value:_ `true`.
564564+565565+`extension` (String or Null; _optional_)
566566+: If set, the archive downloaded by `fetchzip` will be renamed to a filename with the extension specified in this attribute.
567567+568568+ This is useful when making `fetchzip` support additional types of archives, because the implementation may use the extension of an archive to determine whether they can decompress it.
569569+ If the URL you're using to download the contents doesn't end with the extension associated with the archive, use this attribute to fix the filename of the archive.
570570+571571+ This attribute is **not** passed through to `fetchurl`.
572572+573573+ _Default value:_ `null`.
574574+575575+`recursiveHash` (Boolean; _optional_)
576576+: Works [as defined in `fetchurl`](#sec-pkgs-fetchers-fetchurl-inputs-recursiveHash), but its default value is different than for `fetchurl`.
577577+578578+ _Default value:_ `true`.
579579+580580+`downloadToTemp` (Boolean; _optional_)
581581+: Works [as defined in `fetchurl`](#sec-pkgs-fetchers-fetchurl-inputs-downloadToTemp), but its default value is different than for `fetchurl`.
582582+583583+ _Default value:_ `true`.
584584+585585+`extraPostFetch` **DEPRECATED**
586586+: This attribute is deprecated.
587587+ Please use `postFetch` instead.
588588+589589+ This attribute is **not** passed through to `fetchurl`.
590590+591591+### Examples {#sec-pkgs-fetchers-fetchzip-examples}
592592+593593+::::{.example #ex-fetchers-fetchzip-simple-striproot}
594594+# Using `fetchzip` to output contents directly
595595+596596+The following recipe shows how to use `fetchzip` to decompress a `.tar.gz` archive:
531597532598```nix
533599{ fetchzip }:
···536602 hash = "sha256-3ABYlME9R8klcpJ7MQpyFEFwHmxDDEzIYBqu/CpDYmg=";
537603}
538604```
605605+606606+This archive has all its contents in a directory named `patchelf-0.18.0`.
607607+This means that after decompressing, you'd have to enter this directory to see the contents of the archive.
608608+However, `fetchzip` makes this easier through the attribute `stripRoot` (enabled by default).
609609+610610+After building the recipe, the derivation output will show all the files in the archive at the top level:
611611+612612+```shell
613613+$ nix-build
614614+(output removed for clarity)
615615+/nix/store/1b7h3fvmgrcddvs0m299hnqxlgli1yjw-source
616616+617617+$ ls /nix/store/1b7h3fvmgrcddvs0m299hnqxlgli1yjw-source
618618+aclocal.m4 completions configure.ac m4 Makefile.in patchelf.spec README.md tests
619619+build-aux configure COPYING Makefile.am patchelf.1 patchelf.spec.in src version
620620+```
621621+622622+If `stripRoot` is set to `false`, the derivation output will be the decompressed archive as-is:
623623+624624+```nix
625625+{ fetchzip }:
626626+fetchzip {
627627+ url = "https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.gz";
628628+ hash = "sha256-uv3FuKE4DqpHT3yfE0qcnq0gYjDNQNKZEZt2+PUAneg=";
629629+ stripRoot = false;
630630+}
631631+```
632632+633633+:::{.caution}
634634+The hash changed!
635635+Whenever changing attributes of a Nixpkgs fetcher, [remember to invalidate the hash](#chap-pkgs-fetchers-caveats), otherwise you won't get the results you're expecting!
636636+:::
637637+638638+After building the recipe:
639639+640640+```shell
641641+$ nix-build
642642+(output removed for clarity)
643643+/nix/store/2hy5bxw7xgbgxkn0i4x6hjr8w3dbx16c-source
644644+645645+$ ls /nix/store/2hy5bxw7xgbgxkn0i4x6hjr8w3dbx16c-source
646646+patchelf-0.18.0
647647+```
648648+::::
649649+650650+::::{.example #ex-fetchers-fetchzip-rar-archive}
651651+# Using `fetchzip` to decompress a `.rar` file
652652+653653+The `unrar` package provides a [setup hook](#ssec-setup-hooks) to decompress `.rar` archives during the [unpack phase](#ssec-unpack-phase), which can be used with `fetchzip` to decompress those archives:
654654+655655+```nix
656656+{ fetchzip, unrar }:
657657+fetchzip {
658658+ url = "https://archive.org/download/SpaceCadet_Plus95/Space_Cadet.rar";
659659+ hash = "sha256-fC+zsR8BY6vXpUkVd6i1jF0IZZxVKVvNi6VWCKT+pA4=";
660660+ stripRoot = false;
661661+ nativeBuildInputs = [ unrar ];
662662+}
663663+```
664664+665665+Since this particular `.rar` file doesn't put its contents in a directory inside the archive, `stripRoot` must be set to `false`.
666666+667667+After building the recipe, the derivation output will show the decompressed files:
668668+669669+```shell
670670+$ nix-build
671671+(output removed for clarity)
672672+/nix/store/zpn7knxfva6rfjja2gbb4p3l9w1f0d36-source
673673+674674+$ ls /nix/store/zpn7knxfva6rfjja2gbb4p3l9w1f0d36-source
675675+FONT.DAT PINBALL.DAT PINBALL.EXE PINBALL2.MID TABLE.BMP WMCONFIG.EXE
676676+MSCREATE.DIR PINBALL.DOC PINBALL.MID Sounds WAVEMIX.INF
677677+```
678678+::::
539679540680## `fetchpatch` {#fetchpatch}
541681