@imp/rules/imp/lockfile
Module: @imp/rules/imp/lockfile.
download_tool_artifact(options)
Download a toolchain artifact. By default, verify it against its lockfile. Each toolchain install task uses this download step with its own extract or install task.
The function reads the lockfile when it declares the task. The task
resolves the entry (a miss is an error, or a warning when unverified),
runs the verified download, and adds a gen-lockfiles pointer to a failed
transfer or a size or SHA-256 mismatch.
Options:
lockfile Lockfile address, for example "@imp/rules/c/mold/mold.lock".
tool Lockfile tool stem, for example "mold".
version Toolchain version.
plat Host platform { os, arch }. It selects the script tools.
lock_plat Optional platform key for the lockfile lookup when it is
not the host platform, for example { os = "any", arch = "any" } for a platform-independent artifact.
url Fallback URL when no lock entry resolves.
output Sandbox-relative destination path.
display Optional task display label.
unverified Optional. Make a lockfile miss a warning, and download
without verification.
Returns the artifact handle of the downloaded file.
Source: rules/imp/lockfile/index.luau:216.
locked_download_argv(options)
argv of an action that downloads a toolchain artifact to download_path.
With a lock_entry (from resolve_tool_lockfile), the action verifies
the SHA-256, and the byte size when the entry has one. A mismatch makes
the action fail. Without a lock_entry, the action downloads url and
does not verify it.
Options: plat, lock_entry (or nil), url, download_path, and
display_name (the argv[0] label of the script, for example
"download-ruff").
Source: rules/imp/lockfile/index.luau:158.
locked_download_tools(plat)
Native-tool names that the download script needs. The sandbox is
hermetic, so it declares coreutils too. A bare sh resolves only on Unix,
so the list declares sh on Windows only.
Source: rules/imp/lockfile/index.luau:141.
lockfile_address_to_path(address)
Convert a lockfile address to the workspace-relative path where
gen-lockfiles writes it. @workspace/a/b.lock becomes a/b.lock.
@imp/rules/a/b.lock becomes rules/a/b.lock, the source path of the
shipped rule library in the Imp repository.
Source: rules/imp/lockfile/index.luau:30.
lockfile_for(kind, version, fallback_address)
The lockfile address of a toolchain version: the lockfile of the
instance that declared the version (else of the default instance), or
fallback_address, the address of the lockfile that ships with the rule
library. kind is a kind table from @imp/rules/imp/toolchain. The
caller passes it, so this module does not require the toolchain module.
Source: rules/imp/lockfile/index.luau:53.
resolve_tool_lockfile(options)
Resolve the lockfile entry that pins a toolchain artifact for a version and platform.
Returns { url, artifact, size?, sha256 }. size is absent in entries
from lockfiles that were written before lockfiles became additive. On a
miss, raises an error with a pointer to gen-lockfiles. With
unverified = true, logs a warning and returns nil instead.
Options: address (for example "@imp/rules/python/ruff-toolchain.lock"),
tool (the lockfile tool stem), version, plat ({ os, arch }), and
optional unverified.
Source: rules/imp/lockfile/index.luau:120.
sha_tool_name(plat)
Name of the SHA-256 tool for a platform: shasum on macOS, and
sha256sum on the other platforms (Linux, and Windows through the Git for
Windows shell).
Source: rules/imp/lockfile/index.luau:134.