cd360b329f
The nix invocations come from the garage .nix files
44 lines
1 KiB
Nix
44 lines
1 KiB
Nix
{ system, target ? null, pkgsSrc, cargo2nixOverlay, compiler ? "rustc",
|
|
release ? false, }:
|
|
|
|
let
|
|
pkgs = if target != null then
|
|
import pkgsSrc {
|
|
inherit system;
|
|
crossSystem = {
|
|
config = target;
|
|
isStatic = true;
|
|
};
|
|
overlays = [ cargo2nixOverlay ];
|
|
}
|
|
else
|
|
import pkgsSrc {
|
|
inherit system;
|
|
overlays = [ cargo2nixOverlay ];
|
|
};
|
|
|
|
toolchainOptions = {
|
|
rustVersion = "1.75.0";
|
|
};
|
|
|
|
packageFun = import ./Cargo.nix;
|
|
|
|
codegenOpts = {
|
|
"armv6l-unknown-linux-musleabihf" = [
|
|
"target-feature=+crt-static"
|
|
"link-arg=-static"
|
|
]; # compile as dynamic with static-pie
|
|
"x86_64-unknown-linux-musl" =
|
|
[ "target-feature=+crt-static" "link-arg=-static-pie" ];
|
|
};
|
|
|
|
# NixOS and Rust/Cargo triples do not match for ARM, fix it here.
|
|
rustTarget = if target == "armv6l-unknown-linux-musleabihf" then
|
|
"arm-unknown-linux-musleabihf"
|
|
else
|
|
target;
|
|
|
|
in pkgs.rustBuilder.makePackageSet ({
|
|
inherit release packageFun codegenOpts;
|
|
target = rustTarget;
|
|
} // toolchainOptions)
|