diff --git a/pkgs/by-name/co/codec2/package.nix b/pkgs/by-name/co/codec2/package.nix index f5c82cfb8a51..d68de7cfd4c7 100644 --- a/pkgs/by-name/co/codec2/package.nix +++ b/pkgs/by-name/co/codec2/package.nix @@ -1,6 +1,7 @@ { lib, stdenv, + buildPackages, fetchFromGitHub, cmake, freedvSupport ? false, @@ -18,12 +19,23 @@ stdenv.mkDerivation rec { hash = "sha256-69Mp4o3MgV98Fqfai4txv5jQw2WpoPuoWcwHsNAFPQM="; }; - nativeBuildInputs = [ cmake ]; + nativeBuildInputs = [ + cmake + buildPackages.stdenv.cc # needs to build a C program to run at build time + ]; buildInputs = lib.optionals freedvSupport [ lpcnetfreedv ]; + # we need to unset these variables from stdenv here and then set their equivalents in the cmake flags + # otherwise it will pass the same compiler to the native and cross phases and crash trying to execute + # host binaries (generate_codebook) on the build system. + preConfigure = '' + unset CC + unset CXX + ''; + postInstall = '' install -Dm0755 src/{c2enc,c2sim,freedv_rx,freedv_tx,cohpsk_*,fdmdv_*,fsk_*,ldpc_*,ofdm_*} -t $out/bin/ ''; @@ -37,6 +49,8 @@ stdenv.mkDerivation rec { [ # RPATH of binary /nix/store/.../bin/freedv_rx contains a forbidden reference to /build/ "-DCMAKE_SKIP_BUILD_RPATH=ON" + "-DCMAKE_C_COMPILER=${stdenv.cc.targetPrefix}cc" + "-DCMAKE_CXX_COMPILER=${stdenv.cc.targetPrefix}c++" ] ++ lib.optionals freedvSupport [ "-DLPCNET=ON"