NIX-PREFETCH(1)

πŸ“¦ version 0.4.1, in nixos 26.05, nixpkgs unstable

πŸ’… NAME πŸ’…

nix-prefetch β€” prefetch literally any fetcher function call, like package sources, bestie. No cap.

This is the nix-prefetch manual page from the Command Reference, and we're gonna get through it together 🫢


✨ SYNOPSIS ✨

nix-prefetch [(-A | --attr) <attr>] [(-E | --expr) <expr>] [(-i | --index) <index>] [(-F | --fetcher) (<file> | <attr>)]
             [(-f | --file) <file>] [--fetchurl] [--force-https]
             [--arg <name> <value>] [--argstr <name> <value>] [-I <path>] [--option <name> <value>]
             [(-t | --type | --hash-algo) <hash-algo>] [(-h | --hash) <hash>]
             [--input <input-type>] [--output <output-type>] [--print-urls] [--print-path]
             [--compute-hash] [--check-store] [-s | --silent] [-q | --quiet] [-v | --verbose] [-vv | --debug] ...
             ([-f | --file] <file> | [-A | --attr] <attr> | [-E | --expr] <expr> | <url>) [<hash>]
             [--help | --autocomplete | --eval <expr>]
             [--] [--<name> ((-f | --file) <file> | (-A | --attr) <attr> | (-E | --expr) <expr> | <str>)] ...
nix-prefetch [(-f | --file) <file>] [--deep] [-s | --silent] [-v | --verbose] [-vv | --debug] ... (-l | --list)
nix-prefetch --help
nix-prefetch --version

πŸŽ€ OPTIONS πŸŽ€

Okay so first thing, bestie: all options can be repeated with the last value taken, and they can be placed both before and after the parameters. Iconic behavior honestly.

  • -f <file>, --file <file> β€” when you give it either an attribute or an expression, this has to be a path to Nixpkgs. Otherwise it can be a file directly pointing to a fetcher function or package derivation.
  • -A <attr>, --attr <attr> β€” an attribute path relative to the pkgs of the imported Nixpkgs.
  • -E <expr>, --expr <expr> β€” a Nix expression with the pkgs of the imported Nixpkgs put into scope, evaluating to either a fetcher function or package derivation.
  • -i <index>, --index <index> β€” which element of the list of sources should be used when multiple sources are available.
  • -F (<file> | <attr>), --fetcher (<file> | <attr>) β€” when the fetcher of the source cannot be automatically determined, this option lets you pass it manually instead.
  • --fetchurl β€” fetch only the URL. This converts e.g. the fetcher fetchFromGitHub to fetchurl for its URL, and the hash options will be applied to fetchurl instead. The name argument will be copied over.
  • --force-https β€” rewrite HTTP to HTTPS URLs, if the fetcher allows it [default: true]. No check is done whether HTTPS is actually supported. So like… be aware, bestie.
  • --arg <name> <value> β€” just like nix-instantiate and nix-build, when the expression passed to nix-prefetch results in a function, it will automatically be called, but not all arguments might have default values, so using --arg a value for them can still be supplied.
  • --argstr <name> <value> β€” this option is just like --arg, except that <value> will be considered a Nix string rather than a Nix expression.
  • -I <path> β€” add a path to the Nix search path. See the NIX_PATH environment variable for more information. Paths added through -I take precedence over NIX_PATH.
  • --option <name> <value> β€” set the Nix configuration <name> to <value>. This overrides the settings in the Nix configuration file. See nix.conf(5) for more information.
  • -t <hash-algo>, --type <hash-algo>, --hash-algo <hash-algo> β€” what algorithm should be used for the output hash of the resulting derivation. The following algorithms are allowed: md5 (deprecated), sha1, sha256, or sha512 [default: sha256].
  • -h <hash>, --hash <hash> β€” when the output hash of the resulting derivation is already known, it can be used to check whether it already exists within the Nix store.
  • --input <input-type> β€” specify what type of input should be read from stdin, which will be passed as fetcher arguments. The following types are available:
    • nix β€” a Nix attribute set.
    • json β€” a JSON object.
    • shell β€” lines of name/value pairs separated by an = (equals) sign.
  • --output <output-type> β€” specify what type of output should be written to stdout [default: raw]. The following types are available:
    • nix β€” the arguments passed to the fetcher function as a Nix attribute set.
    • json β€” the arguments passed to the fetcher function as a JSON object.
    • shell β€” the arguments passed to the fetcher function as lines of name/value pairs separated by an = (equals) sign.
    • raw β€” the output hash and, if the --print-path option is passed, the output path as well.
  • --print-urls β€” print the URLs fetched as part of the derivation. Only applicable to --output raw.
  • --print-path β€” print the output path of the resulting derivation. Only applicable to --output raw.
  • --compute-hash β€” whether to compute the hash [default: true].
  • --check-store β€” check whether the Nix store already contains the output path of the resulting derivation. This can be a useful optimization when nix-prefetch is used in automated update scripts, which might try and prefetch things that have not actually been updated and are already installed on the system. Lowkey a lifesaver for scripts, fr fr.
  • --autocomplete β€” list the arguments that can be passed to the fetcher function.
  • --eval <expr> β€” evaluate the Nix expression that should define a function getting an attribute set of the references Nix packages set, the original fetcher, and the new fetcher (i.e. prefetcher). This option is necessary, because some of the information cannot be represented as JSON and are thus only available at runtime. It allows further integration with other tools.
  • -l, --list β€” list the available fetchers in Nixpkgs.
  • --deep β€” rather than only listing the top-level fetchers, deep search Nixpkgs for fetchers (slow).
  • -s, --silent β€” no output to stderr.
  • -q, --quiet β€” no additional output to stderr.
  • -v, --verbose β€” verbose output to stderr.
  • -vv, --debug β€” even more verbose output to stderr (meant for debugging purposes).
  • --help β€” show help message.
  • --version β€” show version information.

πŸ¦‹ EXAMPLES πŸ¦‹

These are literally the moment, bestie. Copy them exactly, okay?

nix-prefetch hello.src
nix-prefetch '{ stdenv, fetchurl }: stdenv.mkDerivation rec {
                 name = "test";
                 src = fetchurl { url = http://ftpmirror.gnu.org/hello/hello-2.10.tar.gz; };
               }'
nix-prefetch hello --check-store --verbose
nix-prefetch git --check-store --verbose
nix-prefetch fetchurl --urls --expr '[ mirror://gnu/hello/hello-2.10.tar.gz ]'
nix-prefetch '{ name }: pkgs.${name}' --argstr name fetchurl --url 'mirror://gnu/hello/hello-2.10.tar.gz'
nix-prefetch openraPackages.engines.bleed --fetchurl --rev master
nix-prefetch hello 0000000000000000000000000000000000000000000000000000
nix-prefetch hello_rs.cargoDeps --fetcher '<nixpkgs/pkgs/build-support/rust/fetchCargoTarball.nix>'
nix-prefetch --list --deep
nix-prefetch fetchFromGitHub --help
nix-prefetch '(import <nixpkgs> { system = "i686-linux"; }).scilab-bin'

🌸 AUTHOR 🌸

Matthijs Steen πŸ’–


And that's the whole vibe check, bestie. This was nix-prefetch version 0.4.1, dated 17/07/2021 β€” go forth and prefetch slayfully πŸ‘‘βœ¨
πŸ“¦ where this page comes from