anchor.diff: -{ stdenv, callPackage, fetchFromGitHub, bash, makeWrapper, ncurses, bat
  -# batgrep and batwatch
  +{ stdenv, callPackage, fetchFromGitHub, bash, makeWrapper, bat
  +# batdiff, batgrep, and batwatch
  +, coreutils
   , less
   # batgrep
   , ripgrep
  
positive.code:     stdenv.lib.optional cond dep;
  in
  {
    batgrep = script "batgrep" [ less ripgrep ];
    batman = (script "batman" []).overrideAttrs (drv: {
      doCheck = stdenv.isDarwin; # test fails on Linux due to SIGPIPE (eth-p/bat-extras#19)
    });
    batwatch = script "batwatch" ([ less ] ++ optionalDep withEntr entr);
    prettybat = (script "prettybat" ([]
      ++ optionalDep withShFmt shfmt
      ++ optionalDep withPrettier nodePackages.prettier
      ++ optionalDep withClangTools clang-tools
      ++ optionalDep withRustFmt rustfmt)
    ).overrideAttrs (drv: {
      doCheck = stdenv.isDarwin; # test fails on Linux due to SIGPIPE (eth-p/bat-extras#19)
    });
  }
  
negative.code: , withRustFmt ? rustfmt != null, rustfmt ? null
  # batwatch
  , withEntr ? entr != null, entr ? null
  # batdiff
  , gitMinimal
  , withDelta ? gitAndTools?delta, gitAndTools ? null
  }:
  
  let
    # Core derivation that all the others are based on.
    # This includes the complete source so the per-script derivations can run the tests.
    core = stdenv.mkDerivation rec {
      pname   = "bat-extras";
      # there hasn't been a release since 2020-05-01 but there are important bugfixes
      # to the test suite so we'll pull the latest commit as of 2020-06-17.
      version = "20200515-dev"; # latest commit was dated 2020-05-15
  
      src = fetchFromGitHub {
        owner  = "eth-p";
        repo   = pname;
        rev    = "3029b6749f61f7514e9eef30e035cfab0e31eb1d";
        sha256 = "08mb94k2n182ql97c5s5j1v7np25ivynn5g0418whrx11ra41wr7";
        fetchSubmodules = true;
      };
  
      # bat needs to be in the PATH during building so EXECUTABLE_BAT picks it up
      nativeBuildInputs = [ bash bat ];
  
      dontConfigure = true;
  
      postPatch = ''
        patchShebangs --build test.sh test/shimexec .test-framework/bin/best.sh
      '';
  
      buildPhase = ''
  