Multiple Sources and patches
A Pin has one Checker and one Version, but can declare multiple Sources. You choose each Source's name. Each has its own Fetcher, source Hash, and Packages.
{ pin }: {
patchelf = pin.mk {
checker = pin.checker.github { target = "NixOS/patchelf"; };
sources = {
archive = {
fetcher = pin.fetcher.github { target = "NixOS/patchelf"; };
};
checkout = {
fetcher = pin.fetcher.git {
target = "https://github.com/NixOS/patchelf.git";
};
};
};
};
}
The Reader paths are pins.patchelf.sources.archive.src and pins.patchelf.sources.checkout.src. Both Sources share the same release Version. If either fails, the entire Pin keeps its previous result.
Patch each Source
A Source can configure patches and postPatch. With the single-Source shorthand, these fields can also be set directly on pin.mk or a convenience constructor:
{ pin }: {
patchelf = pin.github {
target = "NixOS/patchelf";
postPatch = ''
test -f README.md
'';
};
}
The source hash covers the original Fetcher contents. The patched src is used by Packages and by the Reader when a configuration is supplied. To have the Reader apply these patches, pass config as well; see Reader. Patches and postPatch come from trusted Nix configuration.
When using sources, put the complete declaration in each Source. Do not also rely on the top-level single-Source shorthand: explicit sources takes precedence.