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),
|
2019-09-26 23:17:31 +08:00
|
|
|
rustManifest ? ./channel-rust-nightly.toml,
|
2019-05-05 20:56:23 +08:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pkgs = import <nixpkgs> { overlays = [ mozillaOverlay ]; };
|
2019-09-27 05:34:06 +08:00
|
|
|
rustcSrc = pkgs.fetchgit {
|
2019-08-07 01:47:45 +08:00
|
|
|
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";
|
2019-08-07 01:47:45 +08:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
2019-09-26 23:17:31 +08:00
|
|
|
targets = [];
|
2019-09-27 05:34:06 +08:00
|
|
|
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;
|
2019-09-27 05:34:06 +08:00
|
|
|
rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform {
|
2019-08-07 01:47:45 +08:00
|
|
|
rustc = rust // { src = rustcSrc; };
|
2019-05-05 20:56:23 +08:00
|
|
|
cargo = rust;
|
|
|
|
});
|
2019-09-27 05:34:06 +08:00
|
|
|
gcc = pkgs.pkgsCross.armv7l-hf-multiplatform.buildPackages.gcc;
|
2019-09-26 23:54:37 +08:00
|
|
|
xbuildRustPackage = attrs:
|
2019-09-27 05:34:06 +08:00
|
|
|
let
|
|
|
|
buildPkg = rustPlatform.buildRustPackage attrs;
|
|
|
|
in
|
|
|
|
buildPkg.overrideAttrs ({ name, nativeBuildInputs, ... }: {
|
2019-09-26 23:54:37 +08:00
|
|
|
nativeBuildInputs =
|
2019-09-27 05:34:06 +08:00
|
|
|
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 = ./.;
|
2019-12-18 06:35:58 +08:00
|
|
|
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
|
|
|
}
|