Key or variableMeaning
:sourceThe precompiled API URL. Default: https://compatibility.nerves-project.org/api/precompiled. https only (http on loopback). Config only.
:exceptDependencies never installed precompiled, e.g. [:ash].
:contentContent origins (mirrors, CDNs) to fetch files and manifests from instead of the ones the signed batch names. https only (http on loopback). Config only.
:rootA root.json to trust instead of the one this library ships. Config only.
:home / PRECOMPILED_HOMECache and trust state dir. The config key beats the variable. Default: the user cache dir (:filename.basedir(:user_cache, "precompiled")). PRECOMPILED_HOME=~/.nerves/precompiled keeps using the pre-rename cache.
:deadline_secondsAll network for one run (default 300); what is still waiting then compiles. Root and batch get 15 s together, connects 5 s.
:root_check_secondsHow often the served root is checked for a rotation (default 3600; a batch that fails to verify checks it at once).
:cache_max_mbCache size bound (default 4096), least recently used evicted, checked once a day. Last use is recorded at most once a day per entry, so the eviction order is approximate within a day. Trust state is never evicted.
PRECOMPILED=0Off: installs nothing and removes earlier installs.
PRECOMPILED_OFFLINE=1No network: the cached batch (while fresh) and cached files only.
PRECOMPILED_CACERTS_PATH (or HEX_CACERTS_PATH)A PEM CA bundle that replaces the OS store (TLS-intercepting proxies). Verification stays on; only the bundle's CAs are trusted.
HTTPS_PROXY/https_proxy, HTTP_PROXY/http_proxy, NO_PROXY/no_proxyProxies, as Hex reads them. Credentials in the proxy URL are sent only to the proxy. NO_PROXY takes host names, domains (.corp.example), IP addresses and *; CIDR ranges are ignored.
PRECOMPILED_DEBUG=1Also print each dependency that was not a candidate, and why.
PRECOMPILED_COMPILE_CACHE=0Compile this library itself on every fresh _build, instead of reusing its own compiled modules from deps/precompiled/.compile_cache (see below).

The keys go in config :precompiled, ...; Precompiled.Host.install/2 also takes :except and :home as options. :source, :root and :content are project config only: no option or environment variable sets them, because a source or mirror learns which dependencies you use and a root decides whose builds run (see Trust). The old names (config :nerves_precompiled, config :nerves, :precompiled, NERVES_PRECOMPILED*) are still read for one release, when the new ones are unset.

Turning it off

  • PRECOMPILED=0 (false and no work too) turns it off and removes the builds it installed, so Mix compiles them in that same run. Only build dirs this library wrote are removed, never one Mix compiled, and only in the _build of the run's own env and target: a run on host removes host installs, never a device target's.
  • mix precompiled.clean removes this _build's installs. --cache also empties the download cache (files, manifests, systems tables and source scans), from the same cache dir a run uses.
  • :except keeps listed dependencies compiled from source; an earlier install of one is removed.

This library's own compile

The deps.compile precompiled step compiles this library before it can install anything. As a dependency fetched from Hex it keeps its compiled modules in deps/precompiled/.compile_cache, so a fresh _build (another MIX_ENV or MIX_TARGET, rm -rf _build, mix clean --deps) restores them instead of compiling again. The entry is keyed on the Elixir and OTP versions, the compiler options, every source file of the library and the project's config :precompiled; each restored file is checked against the sha256 recorded when it was saved, and Mix still checks the restored build as it checks its own. It lives in the deps dir, so it trusts nothing that the sources Mix compiles do not already. Only a dependency Hex fetched is written to: a path or git checkout of this library, an unpacked Hex package used as a path dependency included, is never written to. mix deps.clean precompiled removes it with the sources.

One entry is kept per deps dir. CI that shares one deps/ across several Elixir or OTP versions replaces the entry on every version change, so it compiles the library each time as before: it loses the speed-up, never correctness.

Seeing what happened

Every candidate prints one line, then a summary:

precompiled: ash 3.36.0                   HIT   4.1 MB; build 3f2a9c01b7de: Elixir 1.20.0/OTP 28
precompiled: nerves_pack 0.7.1            MISS  built with nerves_ssh 1.3.3, project has 1.3.2
precompiled: 40 hit, 5 miss, 0 fail of 45 deps, 61.2 MB, 8.3 s

A warm run whose installs the batch still vouches for prints nothing.

  • mix precompiled.status lists what is installed in this _build, with the batch and manifest each came from.
  • _build/<env>/lib/.precompiled/report.json ("format": 1) holds the last run that printed lines.
  • Each installed dependency carries .mix/precompiled.json.