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;
2019-11-11 07:28:46 +08:00
# master of 2019-11-09
rev = "ac162c6abe34cdf965afc0389f6cefa79653c63b";
sha256 = "06c5gws1mrpr69z1gzs358zf7hcsg6ky8n4ha0vv2s9d9w93x1kj";
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 = ./.;
2019-11-11 07:45:33 +08:00
cargoSha256 = "1k7b0bzkzhqggrmgzs7md7rrbid0b59a5l96ppr4rwxnh841vcdk";
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
}