NIX-PREFETCH(1)
π 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 fetcherfetchFromGitHubtofetchurlfor its URL, and the hash options will be applied tofetchurlinstead. Thenameargument 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 likenix-instantiateandnix-build, when the expression passed tonix-prefetchresults in a function, it will automatically be called, but not all arguments might have default values, so using--arga 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 theNIX_PATHenvironment variable for more information. Paths added through-Itake precedence overNIX_PATH.--option<name> <value> β set the Nix configuration <name> to <value>. This overrides the settings in the Nix configuration file. Seenix.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, orsha512[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-pathoption 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 whennix-prefetchis 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 wasnix-prefetchversion0.4.1, dated17/07/2021β go forth and prefetch slayfully πβ¨
π¦ where this page comes from
- nixos 26.05: nix-prefetch 0.4.1
- nixpkgs unstable: nix-prefetch 0.4.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms