anchor.diff: -{ stdenv, pkgs, fetchFromGitHub, autoconf, automake, libtool
  -, python, boost, mpi ? pkgs.openmpi, libxc, fetchpatch, openblas
  -, scalapack, makeWrapper, openssh
  +{ stdenv, lib, pkgs, fetchFromGitHub, autoconf, automake, libtool
  +, python, boost159, mpi ? pkgs.openmpi, libxc, fetchpatch, blas
  +, scalapack ? null, makeWrapper, openssh
   } :
   
   let
  -  version = "1.1.1";
  +  version = "1.1.2";
  +
  +  blasName = (builtins.parseDrvName blas.name).name;
   
     mpiName = (builtins.parseDrvName mpi.name).name;
     mpiType = if mpiName == "openmpi" then mpiName
  
positive.code:     EOF
      chmod 755 $out/bin/bagel
  
      # copy test jobs
      mkdir -p $tests/
      cp test/* $tests 
    '';
  
    installCheckPhase = ''
  
negative.code:        else throw "mpi type ${mpiName} not supported";
  
  in stdenv.mkDerivation {
    name = "bagel-${version}" + lib.optionalString (blasName != "openblas") "-${blasName}";
  
    src = fetchFromGitHub {
      owner = "nubakery";
      repo = "bagel";
      rev = "v${version}";
      sha256 = "1c6pz3b73i4mly0pw1gv5cn1p88b1gjjyqn5nh1xspp3pfls6fs5";
    };
  
    nativeBuildInputs = [ autoconf automake libtool openssh boost159 ];
    buildInputs = [ python boost159 libxc blas mpi ] 
                  ++ lib.optional (scalapack != null) scalapack;
  
    #
    # Furthermore, if relativistic calculations fail without MKL,
    # users may consider reconfiguring and recompiling with -DZDOT_RETURN in CXXFLAGS.
    CXXFLAGS="-DNDEBUG -O3 -mavx -DCOMPILE_J_ORB "
             + lib.optionalString (blasName == "openblas") "-lopenblas -DZDOT_RETURN"
             + lib.optionalString (blasName == "mkl") "-L${blas}/lib/intel64";
  
    LDFLAGS = lib.optionalString (blasName == "mkl") "-L${blas}/lib/intel64";
  
    BOOST_ROOT=boost159;
  
    configureFlags = [ "--with-libxc" "--with-mpi=${mpiType}" "--with-boost=${boost159}" ] 
                     ++ lib.optional ( blasName == "mkl" ) "--enable-mkl";
  
  #  outputs = [ "out" ];
  
    postPatch = ''
      # Fixed upstream
  