Home Explore Blog Models CI



nix

src/nix/store-prefetch-file.md
43bcaddd27d617af8bcc33e7e26f3d998b8e3e3478087e6b00000003000003be
R""(

# Examples

* Download a file to the Nix store:

  ```console
  # nix store prefetch-file https://releases.nixos.org/nix/nix-2.3.10/nix-2.3.10.tar.xz
  Downloaded 'https://releases.nixos.org/nix/nix-2.3.10/nix-2.3.10.tar.xz' to
  '/nix/store/vbdbi42hgnc4h7pyqzp6h2yf77kw93aw-source' (hash
  'sha256-qKheVd5D0BervxMDbt+1hnTKE2aRWC8XCAwc0SeHt6s=').
  ```

* Download a file and get the SHA-512 hash:

  ```console
  # nix store prefetch-file --json --hash-type sha512 \
      https://releases.nixos.org/nix/nix-2.3.10/nix-2.3.10.tar.xz \
    | jq -r .hash
  sha512-6XJxfym0TNH9knxeH4ZOvns6wElFy3uahunl2hJgovACCMEMXSy42s69zWVyGJALXTI+86tpDJGlIcAySEKBbA==
  ```

# Description

This command downloads the file *url* to the Nix store. It prints out
the resulting store path and the cryptographic hash of the contents of
the file.

The name component of the store path defaults to the last component of
*url*, but this can be overridden using `--name`.

)""

Chunks
18a9602e (1st chunk of `src/nix/store-prefetch-file.md`)
Title: Nix Store Prefetch-File Command: Examples and Description
Summary
This document describes the `nix store prefetch-file` command, which downloads a specified URL to the Nix store. It provides examples demonstrating how to download a file and obtain its store path and cryptographic hash, as well as how to get the SHA-512 hash in JSON format. The command outputs the resulting store path and the file's hash, with the store path's name defaulting to the last component of the URL, although this can be customized with the `--name` option.