crate2nix
crate2nix copied to clipboard
aws-lc-rs
When attempting to build a project making use of the aws-lc-rs crate, the build.rs script fails due to expecting (but not finding) the environment variable allowing it to locate the aws-lc-sys (or aws-lc-fips) library.
A minimal setup to reproduce this is available at https://github.com/0xADD1E/min-aws-lc-rs-borked and an excerpt from the build log is as follows.
@nix { "action": "setPhase", "phase": "configurePhase" }
Running cd .
Building build.rs (aws_lc_rs)
Running rustc --crate-name build_script_build build.rs --crate-type bin -C opt-level=3 -C codegen-units=1 --edition 2021 --cfg feature="aws-lc-sys" --cfg feature="prebuilt-nasm" --out-dir target/build/aws-lc-rs --emit=dep-info,link -L dependency=target/buildDeps --cap-lints allow --color always
thread 'main' panicked at build.rs:59:5:
missing DEP_AWS_LC_ include
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: build_script_build::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
The source of this - https://github.com/aws/aws-lc-rs/blob/c4b8050ba1cdb45835d1460b69fc758b0b63f206/aws-lc-rs/build.rs#L27 - seems perfectly reasonable, but it's not clear how (or if) crate overrides would be used to fix this or if another method is needed.
Cargo's docs on these env vars. I think this needs fixing on both the buildRustCrate and crate2nix sides, specifically:
- buildRustCrate returns the key-value metadata set by the build script somehow
- buildRustCrate learns to plumb in metadata from dependencies, as provided by the upper layer driving it (i.e., crate2nix), as
DEP_env vars - crate2nix keeps track of the key-value metadata from each package and feeds the appropriate sets back in
With https://github.com/NixOS/nixpkgs/pull/401965 merged this issue is now resolved. Thanks @0xADD1E for https://github.com/0xADD1E/min-aws-lc-rs-borked it helped a lot.