fetch

package
v0.0.0-...-1d82e13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: GPL-3.0 Imports: 34 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fetch downloads and verifies sources and adds them to the store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckValid

func CheckValid(ctx context.Context, f Fetcher, reqs []Request) error

CheckValid asks f's store about the store paths of all pinned requests in one batched validity query. With a store that remembers valid paths (store.WithValidityMemo), the following Ensure of an input that is valid already then runs no Nix command (A312). It only saves work: requests without a pinned hash are left to Ensure, and an error changes nothing Ensure would do.

func StorePath

func StorePath(r Request) (string, error)

StorePath is the store path Ensure makes valid for r (r must be pinned).

Types

type Fetcher

type Fetcher interface {
	// Ensure makes the store path valid and returns it: already valid, then substituters
	// (nix-store --realise of the path), then origin URLs. It never runs a Nix FOD.
	Ensure(ctx context.Context, r Request) (storePath string, err error)
	// Resolve downloads without a known NarHash (bob lock) and returns the hashes to record.
	Resolve(ctx context.Context, r Request) (hash, narHash string, err error)
}

Fetcher gets every external input.

func New

func New(st *store.Store, p Policy) Fetcher

New returns a Fetcher that imports into st.

type Kind

type Kind string

Kind is the shape of a fetched input.

const (
	File    Kind = "file"    // one flat file
	Archive Kind = "archive" // an unpacked tree
)

type Policy

type Policy struct {
	DenyPrivate bool // refuse private, loopback and link-local addresses
}

Policy is the egress policy set by the caller (developers: no restriction).

type Request

type Request struct {
	URLs     []string // mirrors in order
	Kind     Kind     // File (flat) or Archive (unpacked tree)
	Hash     string   // SRI of the downloaded bytes (required for File; checked if set for Archive)
	NarHash  string   // SRI of the unpacked tree (required for Archive)
	Name     string   // store name
	Strip    int      // leading path components to drop (Archive)
	MaxBytes int64    // 0 = 2 GiB
	Label    string   // for error messages
}

Request is one external input (SPEC R-NIX-014).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL