Guides
Combining Checkers and Fetchers
Select versions from registries, Git, or custom commands and choose how to download them independently.
A Checker selects the Version to lock. A Fetcher determines how to obtain the contents of that Version. They do not need to use the same platform.
Get a version from crates.io
{ pin }: {
ripgrep = pin.mk {
checker = pin.checker.crate { target = "ripgrep"; };
fetcher = pin.fetcher.zip {
url = version: "https://github.com/BurntSushi/ripgrep/archive/refs/tags/${version}.tar.gz";
};
};
}
This example reads the version from crates.io but fetches source from a GitHub archive. Before using it, confirm that registry versions match repository tag names. A Fetcher's version mapping does not change the original Version stored in the Pins File.
Track a Git branch
{ pin }: {
project = pin.git {
target = "https://github.com/NixOS/patchelf.git";
mode = "branch";
branch = "master";
};
}
Git's head, branch, and ref modes return a commit ID; tag mode returns the original tag. Even as the branch advances, downstream consumers use the commit locked in the Pins File.
Get a version from npm
{ pin }: {
vite = pin.mk {
checker = pin.checker.npm { target = "vite"; distTag = "latest"; };
fetcher = pin.fetcher.url {
url = version: "https://registry.npmjs.org/vite/-/vite-${version}.tgz";
};
};
}
url keeps the downloaded file, while zip extracts supported archives. Choose based on whether the downstream project needs the file itself or a source directory.