Bare-metal Rust on the Xilinx Zynq ZC706 devkit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

default.nix 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. { # Use master branch of the overlay by default
  2. mozillaOverlay ? import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz),
  3. rustManifest ? ./channel-rust-nightly.toml,
  4. }:
  5. let
  6. pkgs = import <nixpkgs> { overlays = [ mozillaOverlay ]; };
  7. rustcSrc = pkgs.fetchgit {
  8. url = https://github.com/rust-lang/rust.git;
  9. # master of 2019-11-09
  10. rev = "ac162c6abe34cdf965afc0389f6cefa79653c63b";
  11. sha256 = "06c5gws1mrpr69z1gzs358zf7hcsg6ky8n4ha0vv2s9d9w93x1kj";
  12. fetchSubmodules = true;
  13. };
  14. targets = [];
  15. rustChannelOfTargets = _channel: _date: targets:
  16. (pkgs.lib.rustLib.fromManifestFile rustManifest {
  17. inherit (pkgs) stdenv fetchurl patchelf;
  18. }).rust.override { inherit targets; };
  19. rust =
  20. rustChannelOfTargets "nightly" null targets;
  21. rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform {
  22. rustc = rust // { src = rustcSrc; };
  23. cargo = rust;
  24. });
  25. gcc = pkgs.pkgsCross.armv7l-hf-multiplatform.buildPackages.gcc;
  26. xbuildRustPackage = attrs:
  27. let
  28. buildPkg = rustPlatform.buildRustPackage attrs;
  29. in
  30. buildPkg.overrideAttrs ({ name, nativeBuildInputs, ... }: {
  31. nativeBuildInputs =
  32. nativeBuildInputs ++ [ pkgs.cargo-xbuild ];
  33. buildPhase = ''
  34. cargo xbuild --release --frozen
  35. '';
  36. XARGO_RUST_SRC = "${rustcSrc}/src";
  37. installPhase = ''
  38. mkdir $out
  39. cp target/armv7-none-eabihf/release/${name} $out/${name}.elf
  40. '';
  41. });
  42. zc706 = xbuildRustPackage {
  43. name = "zc706";
  44. src = ./.;
  45. cargoSha256 = "15icqy72dck82czpsqz41yjsdar17vpi15v22j6z0zxhzf517rf7";
  46. nativeBuildInputs = [
  47. gcc
  48. ];
  49. doCheck = false;
  50. };
  51. in {
  52. inherit pkgs rustPlatform rustcSrc zc706 gcc;
  53. }