1
0
Fork 0
zynq-rs/default.nix

55 lines
1.7 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-01-26 08:18:57 +08:00
# master of 2020-01-25
rev = "c2d141df59703393c0c683abc259f9a8c3be041a";
sha256 = "0v23ia4sp436yjksbq5m5vdarj481w2z8q3px51kidabdd2282yr";
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;
2019-09-26 23:54:37 +08:00
xbuildRustPackage = 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 = ''
cargo xbuild --release --frozen
'';
XARGO_RUST_SRC = "${rustcSrc}/src";
installPhase = ''
mkdir $out
cp target/armv7-none-eabihf/release/${name} $out/${name}.elf
'';
});
zc706 = xbuildRustPackage {
name = "zc706";
src = ./.;
cargoSha256 = "15icqy72dck82czpsqz41yjsdar17vpi15v22j6z0zxhzf517rf7";
2019-09-26 23:54:37 +08:00
nativeBuildInputs = [
gcc
];
doCheck = false;
};
2019-05-05 20:56:23 +08:00
in {
2019-09-26 23:54:37 +08:00
inherit pkgs rustPlatform rustcSrc zc706 gcc;
2019-05-05 20:56:23 +08:00
}