Repository navigation
Description
Context
This was reporting to me over LinkedIn by Evan Porter (I don't know their handle).
He was asking whether Dynamic Derivations can query their producing derivations (*.drv → *.drv.drv):
$ nix-store -qd $(nix-store -qd ./result)
unknown-deriver
Looks like that works on mainline but not for ca-derivations.
Bug
If a content-addressed derivation produces a path that is already valid, the deriver is not recorded. LocalStore::updatePathInfo updates narSize, hash, ultimate, sigs and ca, but not deriver.
This happens with dynamic derivations. A builder runs nix-instantiate under recursive-nix and copies the .drv to $out. The output path is the path nix-instantiate already registered, with no deriver. nix-store -qd returns unknown-deriver, even though BuildTraceV3 has the producing derivation.
Steps to reproduce
repro.nix:
let
pkgs = import <nixpkgs> { };
innerNix = pkgs.writeText "inner.nix" ''
derivation {
name = "inner";
system = builtins.currentSystem;
builder = "''${builtins.storePath "${pkgs.busybox}"}/bin/sh";
args = [ "-c" "echo hi > $out" ];
}
'';
in
pkgs.runCommand "inner.drv" {
__contentAddressed = true;
outputHashMode = "text";
requiredSystemFeatures = [ "recursive-nix" ];
} ''
cp $(${pkgs.nix}/bin/nix-instantiate ${innerNix}) $out
''$ export NIX_CONFIG="extra-experimental-features = dynamic-derivations ca-derivations recursive-nix"
$ nix build -f repro.nix --store $STORE --print-out-paths --no-link
/nix/store/2qghbrdnm5gvrs9p26kg4y2wnf7900ab-inner.drv
$ nix-store --store $STORE -qd /nix/store/2qghbrdnm5gvrs9p26kg4y2wnf7900ab-inner.drv
unknown-deriver
$ sqlite3 $STORE/nix/var/nix/db/db.sqlite \
"select drvPath from BuildTraceV3 where outputPath = '/nix/store/2qghbrdnm5gvrs9p26kg4y2wnf7900ab-inner.drv'"
p2pbimrwj912pbxhxmzbbv6znsarlc7i-inner.drv.drvExpected behavior
nix-store -qd prints /nix/store/p2pbimrwj912pbxhxmzbbv6znsarlc7i-inner.drv.drv.
A possible fix is to fill in deriver in UpdatePathInfo when it is NULL, e.g. deriver = coalesce(deriver, ?).
Related: #2712
Metadata
nix 2.35.2. The code is the same on master (7d83031e0).
Activity
fzakaria commentedon Nov 14, 2026
CC @tomberek who is leading dyndrv working group.
evanwporter commentedon Nov 14, 2026
yeah i didn't realize this was bug in nix. I thought it was a skill issue
tests/functional: cover CA dynamic derivation deriver lookup
tests/functional: cover CA dynamic derivation deriver lookup
tests/functional: cover CA dynamic derivation deriver lookup