anchor.diff:      };
     }) // (removeAttrs attrs ["makeFlags"]));
   
  +  libutil = netBSDDerivation {
  +    path = "lib/libutil";
  +    version = "8.0";
  +    sha256 = "077syyxd303m4x7avs5nxzk4c9n13d5lyk5aicsacqjvx79qrk3i";
  +    extraPaths = [
  +      (fetchNetBSD "common/lib/libutil" "8.0" "0q3ixrf36lip1dx0gafs0a03qfs5cs7n0myqq7af4jpjd6kh1831")
  +    ];
  +  };
  +
  +  libc = netBSDDerivation {
  +    path = "lib/libc";
  +    version = "8.0";
  +    sha256 = "0lgbc58qgn8kwm3l011x1ml1kgcf7jsgq7hbf0hxhlbvxq5bljl3";
  +    extraPaths = [
  +      (fetchNetBSD "common/lib/libc" "8.0" "1kbhj0vxixvdy9fvsr5y70ri4mlkmim1v9m98sqjlzc1vdiqfqc8")
  +    ];
  +  };
  +
  +  make = netBSDDerivation {
  +    path = "usr.bin/make";
  +    sha256 = "103643qs3w5kiahir6cca2rkm5ink81qbg071qyzk63qvspfq10c";
  +    version = "8.0";
  +    postPatch = ''
  +      # make needs this to pick up our sys make files
  +      export NIX_CFLAGS_COMPILE+=" -D_PATH_DEFSYSPATH=\"$out/share/mk\""
  +
  +      substituteInPlace $NETBSDSRCDIR/share/mk/bsd.prog.mk \
  +        --replace '-Wl,-dynamic-linker=''${_SHLINKER}' "" \
  +        --replace '-Wl,-rpath,''${SHLIBDIR}' ""
  +      substituteInPlace $NETBSDSRCDIR/share/mk/bsd.lib.mk \
  +        --replace '_INSTRANLIB=''${empty(PRESERVE):?-a "''${RANLIB} -t":}' '_INSTRANLIB='
  +      substituteInPlace $NETBSDSRCDIR/share/mk/bsd.kinc.mk \
  +        --replace /bin/rm rm
  +    '' + lib.optionalString stdenv.isDarwin ''
  +      substituteInPlace $NETBSDSRCDIR/share/mk/bsd.sys.mk \
  +        --replace '-Wl,--fatal-warnings' "" \
  +        --replace '-Wl,--warn-shared-textrel' ""
  +      substituteInPlace $NETBSDSRCDIR/share/mk/bsd.lib.mk \
  +        --replace '-Wl,-soname,''${_LIB}.so.''${SHLIB_SOVERSION}' "" \
  +        --replace '-Wl,--whole-archive' "" \
  +        --replace '-Wl,--no-whole-archive' "" \
  +        --replace '-Wl,--warn-shared-textrel' "" \
  +        --replace '-Wl,-Map=''${_LIB}.so.''${SHLIB_SOVERSION}.map' "" \
  +        --replace '-Wl,-rpath,''${SHLIBDIR}' ""
  +    '';
  +    postInstall = ''
  +      make -C $NETBSDSRCDIR/share/mk FILESDIR=/share/mk install
  +    '';
  +    extraPaths = [
  +      (fetchNetBSD "share/mk" "8.0" "033q4w3rmvwznz6m7fn9xcf13chyhwwl8ijj3a9mrn80fkwm55qs")
  +    ];
  +  };
  +
  +  libcurses = netBSDDerivation {
  +    path = "lib/libcurses";
  +    version = "8.0";
  +    sha256 = "0azhzh1910v24dqx45zmh4z4dl63fgsykajrbikx5xfvvmkcq7xs";
  +    buildInputs = [ nbPackages.libterminfo ];
  +    makeFlags = [ "INCSDIR=/include" ];
  +    NIX_CFLAGS_COMPILE = [
  +      "-D__scanflike(a,b)="
  +      "-D__va_list=va_list"
  +      "-D__warn_references(a,b)="
  +    ] ++ lib.optional stdenv.isDarwin "-D__strong_alias(a,b)=";
  +    propagatedBuildInputs = [ nbPackages.compat ];
  +    MKDOC = "no"; # missing vfontedpr
  +    postPatch = ''
  +      substituteInPlace printw.c \
  +        --replace "funopen2(win, NULL, winwrite, NULL, NULL, NULL)" NULL \
  +        --replace "__strong_alias(vwprintw, vw_printw)" 'extern int vwprintw(WINDOW*, const char*, va_list) __attribute__ ((alias ("vw_printw")));'
  +      substituteInPlace scanw.c \
  +        --replace "__strong_alias(vwscanw, vw_scanw)" 'extern int vwscanw(WINDOW*, const char*, va_list) __attribute__ ((alias ("vw_scanw")));'
  +    '';
  +  };
  +
  +  libedit = netBSDDerivation {
  +    path = "lib/libedit";
  +    buildInputs = [ nbPackages.libterminfo libcurses ];
  +    propagatedBuildInputs = [ nbPackages.compat ];
  +    makeFlags = [ "INCSDIR=/include" ];
  +    postPatch = ''
  +      sed -i '1i #undef bool_t' el.h
  +      substituteInPlace config.h \
  +        --replace "#define HAVE_STRUCT_DIRENT_D_NAMLEN 1" ""
  +    '';
  +    NIX_CFLAGS_COMPILE = [
  +      "-D__noinline="
  +      "-D__scanflike(a,b)="
  +      "-D__va_list=va_list"
  +    ];
  +    version = "8.0";
  +    sha256 = "0pmqh2mkfp70bwchiwyrkdyq9jcihx12g1awd6alqi9bpr3f9xmd";
  +  };
  +
     nbPackages = rec {
   
     ##
  
positive.code:     makeFlags = [ "BINDIR=/share" ];
    };
  
    games = netBSDDerivation {
      path = "games";
      sha256 = "1vb4ahmiywgd3q3lzwb34mdd7agdlhsmw077alddkqinvyyxq1jz";
      version = "8.0";
      makeFlags = [ "BINDIR=/bin"
                    "SCRIPTSDIR=/bin" ];
      postPatch = ''
        sed -i '1i #include <time.h>' adventure/save.c
  
        for f in $(find . -name pathnames.h); do
          substituteInPlace $f \
            --replace /usr/share/games $out/share/games \
            --replace /usr/games $out/bin \
            --replace /usr/libexec $out/libexec \
            --replace /usr/bin/more ${less}/bin/less \
            --replace /usr/share/dict ${dict}/share/dict
        done
        substituteInPlace boggle/boggle/bog.h \
          --replace /usr/share/games $out/share/games
        substituteInPlace ching/ching/ching.sh \
          --replace /usr/share $out/share \
          --replace /usr/libexec $out/libexec
        substituteInPlace hunt/huntd/driver.c \
          --replace "(void) setpgrp(getpid(), getpid());" ""
  
        # Disable some games that don't build. They should be possible
        # to build but need to look at how to implement stuff in
        # Linux. macOS is missing gettime. TODO try to get these
        # working.
        disableGame() {
          substituteInPlace Makefile --replace $1 ""
        }
  
        disableGame atc
        disableGame dm
        disableGame dab
        disableGame sail
        disableGame trek
        ${lib.optionalString stdenv.isLinux "disableGame boggle"}
        ${lib.optionalString stdenv.isLinux "disableGame hunt"}
        ${lib.optionalString stdenv.isLinux "disableGame larn"}
        ${lib.optionalString stdenv.isLinux "disableGame phantasia"}
        ${lib.optionalString stdenv.isLinux "disableGame rogue"}
        ${lib.optionalString stdenv.isDarwin "disableGame adventure"}
        ${lib.optionalString stdenv.isDarwin "disableGame factor"}
        ${lib.optionalString stdenv.isDarwin "disableGame gomoku"}
        ${lib.optionalString stdenv.isDarwin "disableGame mille"}
      '';
  
      # HACK strfile needs to be installed first & in the path. The
      # Makefile should do this for us but haven't gotten it to work
      preBuild = ''
        (cd fortune/strfile && make && make BINDIR=/bin install)
        export PATH=$out/bin:$PATH
      '';
  
      postInstall = ''
        substituteInPlace $out/usr/share/games/quiz.db/index \
          --replace /usr $out
      '';
  
      NIX_CFLAGS_COMPILE = [
        "-D__noinline="
        "-D__scanflike(a,b)="
        "-D__va_list=va_list"
        "-DOXTABS=XTABS"
        "-DRANDOM_MAX=RAND_MAX"
        "-DINFTIM=-1"
        (lib.optionalString stdenv.hostPlatform.isMusl "-include sys/ttydefaults.h -include sys/file.h")
        "-DBE32TOH(x)=((void)0)"
        "-DBE64TOH(x)=((void)0)"
        "-D__c99inline=__inline"
      ];
  
      buildInputs = [ compat libcurses libterminfo libressl ];
      extraPaths = [ dict.src who.src ];
    };
  
    finger = netBSDDerivation {
      path = "usr.bin/finger";
      sha256 = "1mbxjdzcbx7xsbn3x1qm1cd0kna07yh61wqxmrrphjhl5gv13ra3";
      version = "8.0";
      NIX_CFLAGS_COMPILE = [
        (if stdenv.isLinux then "-DSUPPORT_UTMP" else "-USUPPORT_UTMP")
        (if stdenv.isDarwin then "-DSUPPORT_UTMPX" else "-USUPPORT_UTMPX")
      ];
      postPatch = ''
        NIX_CFLAGS_COMPILE+=" -I$NETBSDSRCDIR/include"
  
        substituteInPlace extern.h \
          --replace psort _psort
  
        ${who.postPatch}
      '';
      extraPaths = [ who.src ]
                ++ lib.optional stdenv.isDarwin (fetchNetBSD "include/utmp.h" "8.0" "05690fzz0825p2bq0sfyb01mxwd0wa06qryqgqkwpqk9y2xzc7px");
    };
  
    fingerd = netBSDDerivation {
      path = "libexec/fingerd";
      sha256 = "0blcahhgyj1lm0mimrbvgmq3wkjvqk5wy85sdvbs99zxg7da1190";
      version = "8.0";
    };
  
    libedit = netBSDDerivation {
      path = "lib/libedit";
      buildInputs = [ libterminfo libcurses ];
      propagatedBuildInputs = [ compat ];
      makeFlags = [ "INCSDIR=/include" ];
      postPatch = ''
        sed -i '1i #undef bool_t' el.h
        substituteInPlace config.h \
          --replace "#define HAVE_STRUCT_DIRENT_D_NAMLEN 1" ""
      '';
      NIX_CFLAGS_COMPILE = [
        "-D__noinline="
        "-D__scanflike(a,b)="
        "-D__va_list=va_list"
      ];
      version = "8.0";
      sha256 = "0pmqh2mkfp70bwchiwyrkdyq9jcihx12g1awd6alqi9bpr3f9xmd";
    };
  
    libterminfo = netBSDDerivation {
      path = "lib/libterminfo";
      version = "8.0";
      sha256 = "14gp0d6fh6zjnbac2yjhyq5m6rca7gm6q1s9gilhzpdgl9m7vb9r";
      buildInputs = [ compat tic nbperf ];
      MKPIC = if stdenv.isDarwin then "no" else "yes";
      makeFlags = [ "INCSDIR=/include" ];
      postPatch = ''
        substituteInPlace term.c --replace /usr/share $out/share
  
negative.code:     version = "8.0";
      sha256 = "0kk6v9k2bygq0wf9gbinliqzqpzs9bgxn0ndyl2wcv3hh2bmsr9p";
      patches = [ ./locale.patch ];
      NIX_CFLAGS_COMPILE = "-DYESSTR=__YESSTR -DNOSTR=__NOSTR";
    };
  
    };
  