52 lines
1.6 KiB
Nix
52 lines
1.6 KiB
Nix
{ pkgs ? import (builtins.fetchGit { url = git://github.com/NixOS/nixpkgs-channels; }) {},
|
|
}:
|
|
|
|
with pkgs;
|
|
let
|
|
rust-thumb-crates = callPackage ./rust-thumb-crates.nix { inherit (rustPlatform.rust) rustc; };
|
|
llvm-rust-src = fetchFromGitHub {
|
|
owner = "rust-lang";
|
|
repo = "llvm-project";
|
|
rev = "rustc/8.0-2019-03-18";
|
|
sha256 = "0lvlf76yyjk61wl1y6l83w84g8y06vz4mwjcxwxcgdmh480ha8vb";
|
|
};
|
|
lld = llvmPackages_8.lld.override {
|
|
fetch = name: _sha256: builtins.toPath "${llvm-rust-src}/${name}";
|
|
};
|
|
buildStm32Firmware = { name, src, cargoSha256 }:
|
|
rustPlatform.buildRustPackage rec {
|
|
inherit name;
|
|
version = "0.0.0";
|
|
|
|
inherit src cargoSha256;
|
|
|
|
buildInputs = [ lld ];
|
|
buildPhase = ''
|
|
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
|
export RUSTFLAGS="-L ${rust-thumb-crates}/lib/rustlib/thumbv7em-none-eabihf/lib -C linker-flavor=ld.lld -C linker=lld"
|
|
cargo build --release -v -v
|
|
'';
|
|
dontStrip = true;
|
|
dontPatchELF = true;
|
|
|
|
doCheck = false;
|
|
installPhase = ''
|
|
mkdir -p $out $out/nix-support
|
|
cp target/thumbv7em-none-eabihf/release/${name} $out/${name}.elf
|
|
echo file binary-dist $out/${name}.elf >> $out/nix-support/hydra-build-products
|
|
'';
|
|
};
|
|
in
|
|
{
|
|
stabilizer = buildStm32Firmware {
|
|
name = "stabilizer";
|
|
src = <stabilizerSrc>;
|
|
cargoSha256 = "184pr64z71h5wi0n9k2ddjyzklbg1cw5vly4ppgck2q6zlb3qbm4";
|
|
};
|
|
thermostat = buildStm32Firmware {
|
|
name = "thermostat";
|
|
src = <thermostatSrc>;
|
|
cargoSha256 = "1xbnd2j4akdf3fc62frb74vpghspkr58kbya2gyzqqdj2gfzy8dh";
|
|
};
|
|
}
|