1
0
Fork 0
zynq-rs/default.nix

63 lines
2.1 KiB
Nix
Raw Normal View History

2019-05-05 20:56:23 +08:00
{ # Use master branch of the overlay by default
mozillaOverlay ? import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz),
rustManifest ? ./channel-rust-nightly.toml,
2019-05-05 20:56:23 +08:00
}:
let
pkgs = import <nixpkgs> { overlays = [ mozillaOverlay ]; };
rustcSrc = pkgs.fetchgit {
url = https://github.com/rust-lang/rust.git;
2020-04-11 02:46:18 +08:00
# master of 2020-04-10
rev = "94d346360da50f159e0dc777dc9bc3c5b6b51a00";
sha256 = "1hcqdz4w2vqb12rrqqcjbfs5s0w4qwjn7z45d1zh0fzncdcf6f7d";
fetchSubmodules = true;
};
targets = [];
rustChannelOfTargets = _channel: _date: targets:
(pkgs.lib.rustLib.fromManifestFile rustManifest {
inherit (pkgs) stdenv fetchurl patchelf;
}).rust.override { inherit targets; };
2019-05-05 20:56:23 +08:00
rust =
rustChannelOfTargets "nightly" null targets;
rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform {
rustc = rust // { src = rustcSrc; };
2019-05-05 20:56:23 +08:00
cargo = rust;
});
gcc = pkgs.pkgsCross.armv7l-hf-multiplatform.buildPackages.gcc;
2020-01-26 08:45:02 +08:00
xbuildRustPackage = { cargoFeatures, crateSubdir, ... } @ attrs:
let
buildPkg = rustPlatform.buildRustPackage attrs;
in
buildPkg.overrideAttrs ({ name, nativeBuildInputs, ... }: {
2019-09-26 23:54:37 +08:00
nativeBuildInputs =
nativeBuildInputs ++ [ pkgs.cargo-xbuild ];
2019-09-26 23:54:37 +08:00
buildPhase = ''
2020-01-26 08:45:02 +08:00
pushd ${crateSubdir}
cargo xbuild --release --frozen \
--no-default-features \
--features=${cargoFeatures}
popd
2019-09-26 23:54:37 +08:00
'';
XARGO_RUST_SRC = "${rustcSrc}/src";
installPhase = ''
mkdir $out
2020-01-26 08:45:02 +08:00
ls -la target/armv7-none-eabihf/release/
2019-09-26 23:54:37 +08:00
cp target/armv7-none-eabihf/release/${name} $out/${name}.elf
'';
});
2020-01-26 08:50:14 +08:00
xbuildCrate = name: crate: features: xbuildRustPackage rec {
2020-01-26 08:45:02 +08:00
name = "${crate}";
2019-09-26 23:54:37 +08:00
src = ./.;
2020-01-26 08:45:02 +08:00
crateSubdir = crate;
2020-04-25 07:29:38 +08:00
cargoSha256 = "02k72zj6qfbw9y69w3r9a1b1dg9pvkc7cl511hcv4w9rbnn3jlld";
2020-01-26 08:45:02 +08:00
cargoFeatures = features;
2019-09-26 23:54:37 +08:00
doCheck = false;
};
2019-05-05 20:56:23 +08:00
in {
2020-01-26 08:45:02 +08:00
inherit pkgs rustPlatform rustcSrc gcc;
zc706 = {
2020-01-26 08:50:14 +08:00
experiments-zc706 = xbuildCrate "experiments-zc706" "experiments" "target_zc706";
experiments-cora = xbuildCrate "experiments-cora" "experiments" "target_cora_z7_10";
2020-01-26 08:45:02 +08:00
};
2019-05-05 20:56:23 +08:00
}