Closed drakon64 closed 3 months ago
Using a derivation similar to the one described in the documentation:
{
pkgs,
crate2nix,
system,
src,
...
}:
let
cargoNix = crate2nix.tools.${system}.appliedCargoNix {
name = "package";
inherit src;
};
in
cargoNix.rootCrate.build
causes crate2nix to disregard the value of pkgs.crossSystem
. I've also been unable to work out how to pass buildRustCrate
to the build this way.
{
pkgs,
crate2nix,
system,
src,
...
}:
let
generatedCargoNix = crate2nix.tools.${system}.generatedCargoNix {
name = "package";
inherit src;
};
cargoNix = pkgs.callPackage generatedCargoNix { };
in
cargoNix.rootCrate.build
seemingly works. I still need to work out how to use rust-overlay
instead of Rust from Nixpkgs (the examples at https://github.com/NixOS/nixpkgs/blob/fb3d86ee0d57c8cdfc363e2108c37af3887f01b4/doc/languages-frameworks/rust.section.md#options-and-phases-configuration-options-and-phases-configuration don't make sense to me) and how to get crate2nix to use static LibreSSL instead of dynamic OpenSSL, but for now this is good enough.
I'm trying to cross-compile a crate to
x86_64-unknown-linux-musl
. My package is defined as follows:This won't work because the
cargo
package is broken. If I runexport NIXPKGS_ALLOW_BROKEN=1
and rerunnix build
with--impure
Cargo will eventually fail to build because thereadelf
command cannot be found.pkgs
is simply defined in a Flake as:When using a similar setup with Crane, Nix would seemingly not attempt to compile
cargo
from source and use the native Rust compiler with the cross-target enabled.This is with crate2nix 0.14.1 and master.