nix3-store-prefetch-file(1)

    Warning
    This program is experimental (@docroot@/development/experimental-features.md#xp-feature-nix-command) and its interface is subject to change.

Name

nix store prefetch-file - download a file into the Nix store

Synopsis

nix store prefetch-file [option…] url

Examples

•   Download a file to the Nix store:

    # 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:

    # 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.

Options

•   --executable (#opt-executable)

    Make the resulting file executable. Note that this causes the resulting hash to be a NAR hash rather than a flat file hash.

•   --expected-hash (#opt-expected-hash) hash

    The expected hash of the file.

•   --hash-type (#opt-hash-type) hash-algo

    Hash algorithm (md5, sha1, sha256, or sha512).

•   --json (#opt-json)

    Produce output in JSON format, suitable for consumption by another program.

•   --name (#opt-name) name

    Override the name component of the resulting store path. It defaults to the base name of url.

•   --unpack (#opt-unpack)

    Unpack the archive (which must be a tarball or zip file) and add the result to the Nix store.

  Logging-related options

•   --debug (#opt-debug)

    Set the logging verbosity level to ‘debug’.

•   --log-format (#opt-log-format) format

    Set the format of log output; one of raw, internal-json, bar or bar-with-logs.

•   --print-build-logs (#opt-print-build-logs) / -L

    Print full build logs on standard error.

•   --quiet (#opt-quiet)

    Decrease the logging verbosity level.

•   --verbose (#opt-verbose) / -v

    Increase the logging verbosity level.

  Miscellaneous global options

•   --help (#opt-help)

    Show usage information.

•   --offline (#opt-offline)

    Disable substituters and consider all previously downloaded files up-to-date.

•   --option (#opt-option) name value

    Set the Nix configuration setting name to value (overriding nix.conf).

•   --refresh (#opt-refresh)

    Consider all previously downloaded files out-of-date.

•   --version (#opt-version)

    Show version information.

    Note

    See man nix.conf (@docroot@/command-ref/conf-file.md#command-line-flags) for overriding configuration settings with command line flags.