Combining Checkers and Fetchers
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.npm "vite";
}
pin.npm combines the npm Checker and Fetcher and keeps the original .tgz file without installing dependencies. Scoped names such as pin.npm "@scope/pkg" also work. Use pin.mk with pin.fetcher.zip if downstream needs an extracted source directory instead.