anchor.diff:        substituteInPlace crypto/async/arch/async_posix.h \
           --replace '!defined(__ANDROID__) && !defined(__OpenBSD__)' \
                     '!defined(__ANDROID__) && !defined(__OpenBSD__) && 0'
  +    ''
  +    # Move ENGINESDIR into OPENSSLDIR for static builds, in order to move
  +    # it to the separate etc output.
  +    + lib.optionalString static ''
  +      substituteInPlace Configurations/unix-Makefile.tmpl \
  +        --replace 'ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}' \
  +                  'ENGINESDIR=$(OPENSSLDIR)/engines-{- $sover_dirname -}'
       '';
   
  -    outputs = [ "bin" "dev" "out" "man" ] ++ lib.optional withDocs "doc";
  +    outputs = [ "bin" "dev" "out" "man" ]
  +      ++ lib.optional withDocs "doc"
  +      # Separate output for the runtime dependencies of the static build.
  +      # Specifically, move OPENSSLDIR into this output, as its path will be
  +      # compiled into 'libcrypto.a'. This makes it a runtime dependency of
  +      # any package that statically links openssl, so we want to keep that
  +      # output minimal.
  +      ++ lib.optional static "etc";
       setOutputFlags = false;
       separateDebugInfo =
         !stdenv.hostPlatform.isDarwin &&
  
positive.code:       if [ -n "$(echo $out/lib/*.so $out/lib/*.dylib $out/lib/*.dll)" ]; then
            rm "$out/lib/"*.a
        fi
      '') + lib.optionalString (!stdenv.hostPlatform.isWindows)
        # Fix bin/c_rehash's perl interpreter line
        #
  
negative.code:       mv $out/include $dev/
  
        # remove dependency on Perl at runtime
        rm -r $etc/etc/ssl/misc
  
        rmdir $etc/etc/ssl/{certs,private}
      '';
  
      postFixup = lib.optionalString (!stdenv.hostPlatform.isWindows) ''
        # Check to make sure the main output and the static runtime dependencies
        # don't depend on perl
        if grep -r '${buildPackages.perl}' $out $etc; then
          echo "Found an erroneous dependency on perl ^^^" >&2
          exit 1
        fi
  