{ pkgs ? import {} }: let fenix = import (fetchTarball "https://github.com/nix-community/fenix/archive/main.tar.gz") { system = "x86_64-linux"; }; targets = ["i686-unknown-linux-gnu" "x86_64-unknown-linux-gnu"]; fenixToolchain = fenix.stable.toolchain.overrideAttrs (old: { inherit targets; }); in pkgs.rustPlatform.buildRustPackage { name = "my-crate"; src = ./.; cargoLock = { lockFile = ./Cargo.lock; }; nativeBuildInputs = with fenixToolchain; [ rust ] ++ (builtins.concatLists ( map (target: [ (rust.override { inherit targets; }) ]) targets )); buildAndTestSubdir = "."; buildPhase = '' ${builtins.concatStringsSep "\n" (map (target: '' cargo build --release --target ${target} --locked '' ) targets)} ''; installPhase = '' mkdir -p $out/lib ${builtins.concatStringsSep "\n" (map (target: '' cp target/${target}/release/libmy_crate.a $out/lib/libmy_crate-${target}.a '' ) targets)} ''; }