{ pkgs , zig , ... }: { target , cargoLock , src , extraLibs , ... }: let importCargoLock = pkgs.rustPlatform.importCargoLock; cargoSetupHook = pkgs.rustPlatform.cargoSetupHook; stdenv = pkgs.stdenv; targetAsRust = { amd64-linux = "x86_64-unknown-linux-musl"; arm64-linux = "aarch64-unknown-linux-musl"; }.${target}; rust-pkg = import ./rust.nix { inherit pkgs zig; system = "x86_64-linux"; }; libPaths = map (x: "${x}/lib") extraLibs; in stdenv.mkDerivation { name = "yaar-${target}"; inherit src; cargoDeps = importCargoLock cargoLock; RUSTFLAGS = "-C link-self-contained=no " + builtins.concatStringsSep " " (map (p: "-L ${p}") libPaths); hardeningDisable = ["all"]; nativeBuildInputs = [ cargoSetupHook rust-pkg zig pkgs.glibc ]; configurePhase = '' runHook preConfigure runHook postConfigure ''; doCheck = false; strictDeps = true; buildPhase = '' runHook preBuild echo "RUSTFLAGS=$RUSTFLAGS" echo cargo build --target ${targetAsRust} -j $NIX_BUILD_CORES --offline --release cargo build --target ${targetAsRust} -j $NIX_BUILD_CORES --offline --release runHook postBuild ''; installPhase = '' cp target/${targetAsRust}/release/yaar "$out" ''; dontFixup = true; }