Diff-hook not working

I have this module enabled:

{
  nix.settings = {
    # Easier diagnose of non-determinism
    diff-hook = pkgs.writeShellScript "nix-diff-hook" ''
      echo "Checking derivation $3"
      diffoscope "$1" "$2" || true
    '';
    run-diff-hook = true;
  };

  environment.systemPackages = with pkgs; [
    diffoscope
  ];
}

However, when rebuilding a non-reproducible derivation, I see no diff. If I run the nix-diff-hook script passing arguments 1, 2 and 3 as explained in the docs (Verifying Build Reproducibility - Nix 2.28.1 Reference Manual), it works.

Could anybody help me see what’s wrong with that config or why I see no diff please?

Does this work instead?

     diff-hook = pkgs.writeShellScript "nix-diff-hook" ''
       echo "Checking derivation $3"
-      diffoscope "$1" "$2" || true
+      ${pkgs.lib.getExe pkgs.diffoscope} "$1" "$2" || true
    '';

It might be the demon calling the hook. But that is just a quickshot.

Thanks, that was the problem indeed!

I was adding diffoscope to environment.systemPackages and thought it’d be enough like that, but it seems it really needs the absolute path.