crate2nix
crate2nix copied to clipboard
libpulse-binding fails to build
This project looks very useful, however there appear to be some incompatibilities with cargo. In particular, libpulse-binding
fails to build. If there is a way to fix this ad-hoc, it would be appreciated.
Error
builder for '/nix/store/r6rs3kxf26sykad7lhn8ivx1w30y65ii-rust_libpulse-binding-2.16.2.drv' failed with exit code 1; last 10 log lines:
patching sources
configuring
Running cd .
building
Building src/lib.rs (libpulse-binding)
Running rustc --crate-name libpulse_binding src/lib.rs --out-dir target/lib -L dependency=target/deps --cap-lints allow -C opt-level=3 -C codegen-units=16 --remap-path-prefix=/build=/ --extern libc=/nix/store/vnlngvyhd96ffpv203pphmzc2grlx1v5-rust_libc-0.2.77-lib/lib/liblibc-f16d2a09e0.rlib --extern libpulse_sys=/nix/store/3d8c0d3g498vmriv2j7carylvn8h98c4-rust_libpulse-sys-1.13.2-lib/lib/liblibpulse_sys-61efca8ebd.rlib --cfg feature="default" --cfg feature="pa_latest_common" --cfg feature="pa_v12" --cfg feature="pa_v13" --cfg feature="pa_v5" --cfg feature="pa_v6" --cfg feature="pa_v8" --edition 2018 -C metadata=f5858b5f2b -C extra-filename=-f5858b5f2b --crate-type lib -l pulse::libpulse.so.0 --color always
error: renaming of the library `pulse` was specified, however this crate contains no `#[link(...)]` attributes referencing this library.
error: aborting due to previous error
Reproduce
mkdir reproduce
cd reproduce
cargo init
echo 'libpulse-binding = "2.16.2"' >> Cargo.toml
cargo build
# Success
crate2nix generate
nix build -f Cargo.nix
# Error as described above
I have fixed the immediate issue, but the cause is still interesting. For anyone finding this in the future, the fix is
preBuild = "sed s/pulse::libpulse.so.0/pulse/ -i target/*link*";
This is a bit of monkey-typing because I don't know where target/link
comes from, what it means or how it behaves yet. However, it seemed to fix my issue and I've got some other work to do, so I'll leave it at that for now.