Dependencies between Pins
Pins advance as soon as their required results are ready. A fast Pin can finish while another Checker is still running. Checker, download, and Nix evaluation/build limits remain separate; a task waiting for a dependency occupies no worker slot.
Declare an input
pin.ref identifies a result. pin.withInputs binds named references to a function evaluated when those results are ready. Put the binding in Checker or Fetcher arguments, patches, postPatch, or a Package Builder's arguments. Keep Source and Package names declared outside the binding.
{ pin }: {
upstream = pin.github "NixOS/patchelf";
archive = pin.mk {
checker = pin.checker.cmd "printf bundle";
fetcher = pin.fetcher.url {
url = pin.withInputs {
release = pin.ref { pin = "upstream"; result = "version"; };
} (inputs: _: "https://example.com/archive-${inputs.release}.tar.gz");
};
};
}
The archive needs only the upstream Version, so it does not wait for upstream downloads or Packages. Multiple named bindings can depend on different results; shared results are prepared once. Ordinary Nix argument sharing still works without a reference.
result | Additional fields | Ready when | Value |
|---|---|---|---|
version | None | The Checker succeeds | Version string |
source | source | Source Hash is known and the original Source is realized | Original Source derivation |
patchedSource | source | Source patches have been realized | Patched Source derivation |
derivedHash | source, package | The Package's Derived Hash is resolved or validly reused | Hash string |
intermediate | source, package | The dependency FOD is realized using its real hash | Intermediate FOD derivation |
source and package default to default. A missing Pin, Source, Package, invalid result kind, or stage dependency cycle fails validation before Checkers run. A fake-hash probe's expected failure never counts as an artifact. A cached hash can satisfy derivedHash; source, patchedSource, and intermediate still require the actual artifact, rebuilding it if missing. These are dependency artifacts, not final application outputs.
Checker inputs
Bind the command or arguments, rather than executing a Checker inside Nix. Escape values inserted into shell commands:
{ pin, lib }: {
upstream = pin.github "NixOS/patchelf";
matching = pin.mk {
checker = pin.checker.cmd (pin.withInputs {
version = pin.ref { pin = "upstream"; result = "version"; };
} (inputs: "printf '%s' ${lib.escapeShellArg inputs.version}"));
fetcher = pin.fetcher.github { target = "NixOS/patchelf"; };
};
}
The waiting Checker does not occupy checker_jobs. True Checker cycles are rejected. Two independent Checkers whose Sources use each other's Versions are allowed because their stage graph has no cycle.
Source and Package inputs
For a patch script, bind a Source or dependency artifact:
postPatch = pin.withInputs {
patches = pin.ref { pin = "upstream"; source = "patches"; result = "source"; };
prepared = pin.ref { pin = "tools"; result = "patchedSource"; };
deps = pin.ref { pin = "library"; package = "cli"; result = "intermediate"; };
} (inputs: ''
cp ${inputs.patches}/fix.patch ./fix.patch
cp ${inputs.prepared}/generated.h ./generated.h
cp -r ${inputs.deps} ./dependency-inputs
'');
Your own Source can download before these patch inputs are available. A Package-specific dependency belongs in that Builder's arguments, so other Packages keep running:
packages.cli = pin.goModule (pin.withInputs {
hash = pin.ref { pin = "library"; package = "cli"; result = "derivedHash"; };
} (inputs: { root = "."; preBuild = "echo '${inputs.hash}' > dependency-hash"; }));
The interface shows a specific wait target, such as Waiting for upstream.version, separately from waiting for a worker slot and dependency failure. Text output also reports dependency waits.
Selective updates and failures
nix-pins update archive
nix-pins update archive --refresh-dependencies
By default, dependencies outside the selection use the startup Pins File snapshot. Their Checkers do not run; locked Source or Intermediate FOD artifacts may be rebuilt without refreshing their Version. Missing locked results produce an error with the target and a hint to use --refresh-dependencies.
The explicit flag recursively includes only prerequisites, deduplicates shared dependencies, and labels automatically included Pins with (dependency). It does not select reverse consumers or unrelated Pins.
If an upstream Pin later fails in another Source or Package, every selected consumer of its current results is invalidated, even if already finished. Those Pins retain their previous entries; a first failed update writes no incomplete Pin. Independent successful Pins can still be saved, and the command exits nonzero. Consumers of a startup snapshot are not tied to an unrelated current update.
Successful Pins save their consumed input snapshots in the optional inputs field. The Reader uses these snapshots and saved Fetcher parameters, so updating only an upstream Pin later does not change an unchanged consumer's reconstruction. References participate in the actual Nix derivation inputs and existing fingerprint checks. Cancellation stops all stages and leaves the Pins File unchanged; valid hash-cache entries remain reusable.