Checkers
A Checker only selects a Pin's Version. Fetchers obtain source code. Except for cmd, the constructors below accept attribute sets, not the string shorthand supported by pin.github.
GitHub — pin.checker.github
Use target = "owner/repo" or owner and repo, without mixing them. By default, reads GitHub's /releases/latest and uses the original tag_name string. This differs from sorting Git tags.
Optional release filtering fields:
| Field | Type | Default | Meaning |
|---|---|---|---|
mode | string | "release" | "release" checks GitHub Releases; "tag" paginates /tags and selects the highest matching tag |
includePrerelease | bool | false | Allow releases marked as prerelease on GitHub (release mode only) |
include | string | null | Rust regular expression that tag_name must match |
exclude | string | null | Rust regular expression that tag_name must not match |
constraint | string | null | SemVer version requirement (e.g. ^1.2, >=1.0, <2.0); leading v is stripped |
When any of these options is set, the Checker lists /releases in GitHub's newest-first order (paginating automatically across same-origin Link headers up to 10 pages), skips drafts, skips prereleases unless includePrerelease = true, and picks the first matching tag_name. No matching releases causes the Pin to fail.
{ pin }: {
patchelf = pin.mk {
checker = pin.checker.github { target = "NixOS/patchelf"; };
fetcher = pin.fetcher.github { target = "NixOS/patchelf"; };
};
monorepo-cli = pin.mk {
checker = pin.checker.github {
target = "acme/mono";
includePrerelease = true;
include = "^cli-v";
exclude = "-alpha$";
};
fetcher = pin.fetcher.github { target = "acme/mono"; };
};
}
Git — pin.checker.git
Use target or url, without mixing them. Supported modes:
mode | Additional fields | Version |
|---|---|---|
head (default) | None | HEAD commit ID |
branch | Required branch | Branch commit ID |
ref | Required ref | Commit ID for the ref; prefers the peeled commit of an annotated tag |
tag | Optional include, exclude, constraint, sort | Original tag selected after sorting |
include and exclude are Rust regular expressions filtering tag names. sort defaults to semver; lexicographic is also available. Do not use lexical ordering in place of semantic version comparison for versions such as 1.9 and 1.10.
{ pin }: {
patchelf = pin.mk {
checker = pin.checker.git {
target = "https://github.com/NixOS/patchelf.git";
mode = "tag";
include = "^[0-9]+[.][0-9]+[.][0-9]+$";
sort = "semver";
};
fetcher = pin.fetcher.git { target = "https://github.com/NixOS/patchelf.git"; };
};
}
branch is only valid in branch mode, and ref only in ref mode. No matching tags or an unresolvable ref causes the Pin to fail.
crates.io — pin.checker.crate
Use target or name for the crate name. Reads newest_version from crates.io, falling back to max_version if absent. It does not filter exclusively for stable releases.
{ pin }: {
ripgrep = pin.mk {
checker = pin.checker.crate { target = "ripgrep"; };
fetcher = pin.fetcher.url {
url = version: "https://crates.io/api/v1/crates/ripgrep/${version}/download";
};
};
}
Use pin.crate "ripgrep" for the standard crates.io shorthand.
PyPI — pin.checker.pypi
Use target or name for the PyPI project name. Reads info.version from the project's JSON response. Choose the download independently with a version mapping:
{ pin }: {
requests = pin.mk {
checker = pin.checker.pypi { target = "requests"; };
fetcher = pin.fetcher.zip {
url = version: "https://files.pythonhosted.org/packages/source/r/requests/requests-${version}.tar.gz";
};
};
}
Use pin.pypi "requests" for the standard PyPI sdist shorthand.
npm — pin.checker.npm
Use target or name; scoped package names are supported. distTag defaults to latest and selects an entry from the registry's dist-tags. Set another tag such as next as needed. The Checker does not scan and sort all published versions.
{ pin }: {
vite = pin.mk {
checker = pin.checker.npm { target = "vite"; distTag = "latest"; };
fetcher = pin.fetcher.npm { target = "vite"; };
};
}
Use pin.npm "vite" for the same Checker/Fetcher pair. --npm-registry-base controls the Checker's metadata registry only; the npm Fetcher's registry is configured separately.
URL — pin.checker.url
Use target or url, with a required regex. Fetches the URL and matches its text. Uses the first capture group if present, otherwise the entire match. The result must not be empty.
{ pin }: {
patchelf = pin.mk {
checker = pin.checker.url {
target = "https://api.github.com/repos/NixOS/patchelf/releases/latest";
regex = ''"tag_name"[[:space:]]*:[[:space:]]*"([^"]+)"'';
};
fetcher = pin.fetcher.github { target = "NixOS/patchelf"; };
};
}
Command — pin.checker.cmd
Accepts a command string. The command must exit successfully and print a nonempty Version to stdout after trimming leading and trailing whitespace. Useful for fixed versions or upstream sources not covered by built-in Checkers.
{ pin }: {
patchelf = pin.mk {
checker = pin.checker.cmd "printf '0.18.0'";
fetcher = pin.fetcher.github { target = "NixOS/patchelf"; };
};
}
Command configuration is trusted executable input, not a sandbox. Print only the version to stdout and send diagnostics to stderr.
GitLab — pin.checker.gitlab
Use target = "owner/repo" (or nested "group/owner/repo") or explicit owner, repo, optional group, and optional self-hosted domain. Lists GitLab /releases and supports optional include, exclude, and SemVer constraint. Use --gitlab-token / NIX_PINS_GITLAB_TOKEN / GITLAB_TOKEN for private projects or higher limits.
{ pin }: {
demo = pin.gitlab {
target = "acme/group/demo";
constraint = "^1.0";
};
}
OCI / Docker — pin.checker.oci
Resolves an OCI/Docker image tag to its immutable sha256:... digest via Registry v2 (supporting WWW-Authenticate: Bearer token exchange, Basic auth, --oci-token, automatic github_token / gitlab_token reuse for ghcr.io / registry.gitlab.com, and $DOCKER_CONFIG/config.json / ~/.docker/config.json). Pass optional tag (default "latest"), registry, and platform (e.g. "linux/arm64" to select a platform digest from a manifest list).
{ pin }: {
alpine = pin.docker {
target = "alpine";
tag = "3.20";
platform = "linux/arm64";
};
}
Gitea / Forgejo / Codeberg — pin.checker.gitea
Use target = "owner/repo" (or owner and repo) with optional domain (default "codeberg.org"), mode ("release" or "tag"), includePrerelease, include, exclude, and SemVer constraint. Authenticate private instances with --gitea-token / NIX_PINS_GITEA_TOKEN / GITEA_TOKEN.
{ pin }: {
app = pin.gitea {
target = "acme/app";
domain = "codeberg.org";
constraint = "^1.0";
};
}