Skip to content

nix-prefetch-url wrapper

See also documentation for nix-prefetch-url.

Info

All requests to the functions are automatically cached.

prefetch_url async

prefetch_url(
    url: str,
    *,
    unpack: bool = False,
    name: str | None = None,
) -> URLPrefetchResult

Just a fancy wrapper around nix-prefetch-url to handle edge-cases like caching.

Parameters:

  • unpack

    (bool, default: False ) –

    Whether to atomatically unpack the archive (raises an error if the provided URL is not an archive).

  • name

    (str | None, default: None ) –

    A custom name to give in the Nix store.

Raises:

  • URLPrefetchError

    If nix-prefetch-url return non-zero exit code or wrote something to stderr.

prefetch_obj async

prefetch_obj(obj: Prefetchable) -> URLPrefetchResult

Convenience function for objects that implement get_prefetch_url().

This function is practically useless because of superior NURL wrapper.

Example
gh_repo = await github_fetch_rest(owner="foo", repo="bar")
await prefetch_obj(gh_repo)

Is equal to (1e1356f is an arbitrary commit)

await prefetch_url("https://github.com/foo/bar/archive/1e1356f.tar.gz")
Or

await prefetch_url(gh_repo.get_prefetch_url())

Prefetchable

Bases: Protocol

get_prefetch_url

get_prefetch_url() -> str

Response classes

URLPrefetchResult

Bases: NupdModel

hash instance-attribute

hash: str

path instance-attribute

path: str

URLPrefetchError

Bases: NetworkError