Rust & OpenSSL woes

Hrm, I’d caution against using that as a template, the input handling is a bit messy. It’ll work for local builds, but not for the right reasons.

nativeBuildInputs is for stuff that should run on the build machine, buildInputs is for libraries & stuff that should be linked against. You also should not explicitly need openssl.dev in buildInputs, since the dev output should automatically be used.

pkg-config comes with a setup hook. This only executes if it’s in nativeBuildInputs. This setup hook will look for buildInputs which have a pkgconfig directory and add it to the PKG_CONFIG_PATH.

So, if we put packages in the correct input locations to begin with like so:

auto-sound-system = rustPlatform.buildRustPackage {
  pname = "auto-sound-system";
  version = "1.0.0";
  src = /home/rajas/Documents/rust-esp32c3-examples/smart-power-button;
  buildAndTestSubdir = "computer";
  cargoLock.lockFile = ./Cargo.lock;

  nativeBuildInputs = with pkgs; [
    pkg-config
  ];
  buildInputs = with pkgs; [
    openssl
  ];
};

The build will work without having to hack around with PKG_CONFIG_PATH, and cross-compilation won’t break.

10 Likes