builtins.readFile does not accumulate the context strings
Since Nix 2.12 (https://nix.dev/manual/nix/2.22/release-notes/rl-2.12), builtins.readFile restrict the context it receives in its input to what it can find after a refscan.
i.e. the right context equation is the following one: context(readFile(x)) = context(x) \cap refscan(contents of x)
Well, note that since Nix 2.6.1, there were other unknown changes to context strings for readFile as the following reproducer diverges between 2.3 and 2.6.1.
More generally, our readFile implements no context string accumulation, it's normal, builtins.readFile a-drv-with-ctx will induce IFD, IFD will not work out of the box with a dummy store and cause panics of Tvix for the time being.
Thankfully, this is a mega niche feature that seems unlikely to be used in nixpkgs at all based on a simple rg readFile nixos/, and the rest of nixpkgs is not supposed to IFD for Hydra.
Reproducer: https://0x0.st/XWa0.txt
Possible root cause for 2.6.1 which was not figured out in the release notes: https://github.com/nixos/nix/commit/3a5f51a3ad7dbfc376aaa86f96f04e93424c305e.
raitobezarius at 2024-08-10T22·38+00
This is actually it, IMHO.
Pretty easy to test:
nix-repl> :l <nixpkgs> nix-repl> :b pkgs.runCommand "see" { } "echo ${pkgs.systemd}/bin/systemd > $out" This derivation produced the following outputs: out -> /nix/store/5rvh9za3l8w0kbixmx5pr03nnqwllqrz-see nix-repl> builtins.getContext (builtins.readFile "/nix/store/5rvh9za3l8w0kbixmx5pr03nnqwllqrz-see") { "/nix/store/0zmji8sw3jm1j4akllcwc6g7i8cilyza-systemd-256.2" = { ... };
This means that
context(readFile(x)) = context(referencesOfStorePathInducedBy(x))whenxis a string without context and a valid store path.raitobezarius at 2024-08-10T22·41+00