NixOS / NixOS/nix

The FOD hash mismatch error message is missing from nix logs

Open
#8,166 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
17.7k
Forks
2k
Avg merge
1d 16h
Merged PRs (30d)
80

Description

Describe the bug

After building an incorrect FOD, the hash mismatch error message is missing from the log outputs.

Steps To Reproduce

  1. Create this dummy incorrect FOD:
{ pkgs ? import <nixpkgs> {} }:

pkgs.stdenv.mkDerivation {
  pname = "repro";
  version = "0.0";
  src = ./.;
  buildPhase = ''
    echo "hello" > $out
  '';
  outputHash = "sha256-0000000000000000000000000000000000000000000=";
}
  1. Build the FOD: nix-build repro.nix.
  2. As expected, you get a hash mismatch error in your terminal:
/tmp/tmp.pxG0cm4iYE » nix-build repro.nix 
this derivation will be built:
  /nix/store/5z6znk3w5abi34znmdd3c59kmclkkm0h-repro-0.0.drv
building '/nix/store/5z6znk3w5abi34znmdd3c59kmclkkm0h-repro-0.0.drv'...
unpacking sources
unpacking source archive /nix/store/m26g9800hi82lv584ghpzfp09fw2db41-tmp.pxG0cm4iYE
source root is tmp.pxG0cm4iYE
patching sources
configuring
no configure script, doing nothing
building
installing
no Makefile or custom installPhase, doing nothing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/nkrm4gmd6zaxkly9dhqz4cw7lz0sjwjd-repro-0.0
checking for references to /build/ in /nix/store/nkrm4gmd6zaxkly9dhqz4cw7lz0sjwjd-repro-0.0...
patching script interpreter paths in /nix/store/nkrm4gmd6zaxkly9dhqz4cw7lz0sjwjd-repro-0.0
error: hash mismatch in fixed-output derivation '/nix/store/5z6znk3w5abi34znmdd3c59kmclkkm0h-repro-0.0.drv':
         specified: sha256-0000000000000000000000000000000000000000000=
            got:    sha256-WJG1tSLV3whtD/CxEPvZ0hu0/HFjrzTQgoai6Eb2vgM=
  1. Look at the build logs through nix log, the hash mismatch is missing:
/tmp/tmp.pxG0cm4iYE » nix log /nix/store/5z6znk3w5abi34znmdd3c59kmclkkm0h-repro-0.0.drv > logs                        
/tmp/tmp.pxG0cm4iYE » cat logs
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/m26g9800hi82lv584ghpzfp09fw2db41-tmp.pxG0cm4iYE
source root is tmp.pxG0cm4iYE
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
building
@nix { "action": "setPhase", "phase": "installPhase" }
installing
no Makefile or custom installPhase, doing nothing
@nix { "action": "setPhase", "phase": "fixupPhase" }
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/nkrm4gmd6zaxkly9dhqz4cw7lz0sjwjd-repro-0.0
checking for references to /build/ in /nix/store/nkrm4gmd6zaxkly9dhqz4cw7lz0sjwjd-repro-0.0...
patching script interpreter paths in /nix/store/nkrm4gmd6zaxkly9dhqz4cw7lz0sjwjd-repro-0.0

These logs are used by some external tooling such as Hydra. Without the proper hash mismatch error message, the build error root cause is impossible to determine. That's super confusing for end-users.

Expected behavior

The hash mismatch error message should be part of the nix log output.

nix-env --version output

Reproduced on:

  • nix-env (Nix) 2.13.3
  • nix-env (Nix) 2.9.0

Priorities

Add 👍 to issues you find important.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided incorrect FOD, then compare the terminal output from nix-build repro.nix with the output from nix log for the resulting derivation. Trace where the fixed-output hash mismatch is reported and ensure the same error appears in the log output; verify using the shown reproduction steps.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.