anchor.diff:      ];
     };
   
  +  # Don't add this to nativeBuildInputs directly.  Use statHook instead.
     stat = mkDerivation {
       path = "usr.bin/stat";
       version = "8.0";
       sha256 = "0z4r96id2r4cfy443rw2s1n52n186xm0lqvs8s3qjf4314z7r7yh";
       nativeBuildInputs = [ makeMinimal install mandoc groff ];
     };
  +
  +  # stat isn't in POSIX, and NetBSD stat supports a completely
  +  # different range of flags than GNU stat, so including it in PATH
  +  # breaks stdenv.  Work around that with a hook that will point
  +  # NetBSD's build system and NetBSD stat without including it in
  +  # PATH.
  +  statHook = makeSetupHook {
  +    name = "netbsd-stat-hook";
  +  } (writeText "netbsd-stat-hook-impl" ''
  +    makeFlagsArray+=(TOOL_STAT=${netbsd.stat}/bin/stat)
  +  '');
   
     tsort = mkDerivation {
       path = "usr.bin/tsort";
  
positive.code: { stdenv, stdenvNoCC, fetchcvs, lib, groff, mandoc, zlib, bison, flex
  , writeText, buildPackages, splicePackages, symlinkJoin }:
  
  let
    fetchNetBSD = path: version: sha256: fetchcvs {
  
negative.code: 
      extraPaths = [ ];
  
      nativeBuildInputs = [ makeMinimal install tsort lorder mandoc groff statHook ];
      buildInputs = [ compat ];
      # depsBuildBuild = [ buildPackages.stdenv.cc ];
  
  