8000 Deriver not recorded when a CA output path is already valid · Issue #16823 · NixOS/nix · GitHub
[go: up one dir, main page]

Skip to content

Deriver not recorded when a CA output path is already valid #16823

Open

Description

@fzakaria

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.drv

Expected 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

  1. fzakaria commented on Nov 14, 2026

    @fzakaria
    ContributorAuthor

    CC @tomberek who is leading dyndrv working group.

  2. evanwporter commented on Nov 14, 2026

    @evanwporter

    yeah i didn't realize this was bug in nix. I thought it was a skill issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0