Rust & OpenSSL woes

I read this thread, but there is no solution for my problem there.

It looks like Rust support in Nix is rather suboptimal compared to that of Haskell. I’m attempting to build GitHub - soywod/himalaya: 📫 Minimalist CLI email client, written in Rust. with the following default.nix

  pkgs = import <nixpkgs> {};
pkgs.rustPlatform.buildRustPackage rec {
  pname = "himalaya";
  version = "0.0.1";

  src = ./.;

  buildInputs = with pkgs; [

  cargoSha256 = "sha256-i8YKE5Z2xoNyjFktRRVA45zD6Qa0aPNC0AOjHUIglgk=";

  meta = with pkgs.stdenv.lib; {
    description = "...";
    homepage = "";

This throws,

run pkg_config fail: "Failed to run `\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"`: No such file or directory (os error 2)"

--- stderr
thread 'main' panicked at '

Could not find directory of OpenSSL installation, and this `-sys` crate cannot
proceed without this knowledge. If OpenSSL is installed and this crate had
trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
compilation process.

Why? I don’t understand. OpenSSL is specified as a build-time dependency.

After I added OPENSSL_DIR =;,

thread 'main' panicked at 'OpenSSL libdir at `/nix/store/nwyjl66jl3hyyp45rphgbknjm1pqq29j-openssl-1.1.1k-dev/lib` does not contain the required files to either statically or dynamically link OpenSSL', /build/himalaya-0.0.1-vendor.tar.gz/openssl-sys/build/

/nix/store/nwyjl66jl3hyyp45rphgbknjm1pqq29j-openssl-1.1.1k-dev/lib/pkgconfig/ contains:

libcrypto.pc  libssl.pc  openssl.pc

Try putting pkg-config in nativeBuildInputs (which is the more appropriate place for it anyway).

For the record, adding the following worked:

  PKG_CONFIG_PATH = "${}/lib/pkgconfig";

If this is supposed to be configured automatically, then something in nixos-unstable is broken.