1
0
Fork 0
zynq-rs/default.nix

49 lines
1.8 KiB
Nix
Raw Normal View History

2019-05-05 20:56:23 +08:00
let
pkgs = import <nixpkgs> { overlays = [ (import ./nix/mozilla-overlay.nix) ]; };
rustPlatform = (import ./nix/rust-platform.nix { inherit pkgs; });
2020-10-13 18:43:37 +08:00
cargo-xbuild = (pkgs.cargo-xbuild.overrideAttrs(oa: { patches = oa.patches ++ [ ./xbuild_writable_lockfile.diff ]; } ));
cargoSha256Experiments = "034l4sxy4adgd97v0ldk844j6m62v8lflavzhs9wnk82mzihglgp";
cargoSha256SZL = "0p9bvydk8jrzpc57cn7x9k5m89x1g0vfvar7i5gph7q9pvnkh6sh";
build-crate = name: crate: features: cargoSha256:
rustPlatform.buildRustPackage rec {
name = "${crate}";
2021-01-15 07:51:45 +08:00
src = builtins.filterSource (path: type:
baseNameOf path != "target"
) ./.;
inherit cargoSha256;
2021-01-15 11:16:37 +08:00
nativeBuildInputs = [ cargo-xbuild pkgs.llvmPackages_9.clang-unwrapped ];
2019-09-26 23:54:37 +08:00
buildPhase = ''
export XARGO_RUST_SRC="${rustPlatform.rust.rustc}/lib/rustlib/src/rust/library"
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
pushd ${crate}
2020-01-26 08:45:02 +08:00
cargo xbuild --release --frozen \
--no-default-features \
--features=${features}
2020-01-26 08:45:02 +08:00
popd
2019-09-26 23:54:37 +08:00
'';
2019-09-26 23:54:37 +08:00
installPhase = ''
mkdir -p $out $out/nix-support
2019-09-26 23:54:37 +08:00
cp target/armv7-none-eabihf/release/${name} $out/${name}.elf
echo file binary-dist $out/${name}.elf >> $out/nix-support/hydra-build-products
2019-09-26 23:54:37 +08:00
'';
doCheck = false;
dontFixup = true;
};
targetCrates = target: {
"${target}-experiments" = build-crate "${target}-experiments" "experiments" "target_${target}" cargoSha256Experiments;
"${target}-szl" = build-crate "${target}-szl" "szl" "target_${target}" cargoSha256SZL;
};
targets = ["zc706" "coraz7" "redpitaya" "kasli_soc"];
in
{
2020-10-13 18:43:37 +08:00
inherit cargo-xbuild;
zc706-fsbl = import ./nix/fsbl.nix { inherit pkgs; };
} // (builtins.foldl' (results: target:
results // targetCrates target
) {} targets)