humpback-dds/flake.nix

98 lines
3.2 KiB
Nix

{
description = "Firmware for MQTT-controlled 4-channel DDS signal generator using Urukul, Humpback and STM32 NUCLEO.";
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-21.11;
inputs.mozilla-overlay = { url = github:mozilla/nixpkgs-mozilla; flake = false; };
inputs.src-migen = { url = github:m-labs/migen; flake = false; };
outputs = { self, nixpkgs, mozilla-overlay, src-migen }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) ]; };
rustManifest = pkgs.fetchurl {
url = "https://static.rust-lang.org/dist/2020-10-30/channel-rust-nightly.toml";
sha256 = "0iygcwzh8s0lfdghj5809krvzifc1ii1wm4sd3qqn7s0rz1s14hi";
};
migen = pkgs.python3Packages.buildPythonPackage rec {
name = "migen";
src = src-migen;
propagatedBuildInputs = [ pkgs.python3Packages.colorama ];
};
targets = [
"thumbv7em-none-eabihf"
];
rustChannelOfTargets = _channel: _date: targets:
(pkgs.lib.rustLib.fromManifestFile rustManifest {
inherit (pkgs) stdenv lib fetchurl patchelf;
}).rust.override {
inherit targets;
extensions = ["rust-src"];
};
rust = rustChannelOfTargets "nightly" null targets;
rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform {
rustc = rust;
cargo = rust;
});
humpback-dds = rustPlatform.buildRustPackage rec {
name = "humpback-dds";
version = "0.0.0";
src = self;
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"SaiTLS-0.1.0" = "sha256-T3hyASQGZAXGLKfOB3mh33VrvRlYSMc1CJdX4XvDFrQ=";
"rsa-0.3.0" = "sha256-9X2kDAOu0HG94HhwYoUtX/ezq99w7u95XMzn3h/JUwk=";
"minimq-0.1.0" = "sha256-yPqMAwyusZZW7571Jn3QVYK2jqmuSMNU6LiZXRYAGGM=";
"smoltcp-0.6.0" = "sha256-BCqcphWF3AotQfuIFYhDiWIMhh2eUCuqD4MPz4dASQ4=";
};
};
nativeBuildInputs = [
pkgs.llvm
pkgs.yosys
pkgs.nextpnr
pkgs.icestorm
(pkgs.python3.withPackages(ps: [ migen ]))
];
buildPhase = ''
cargo build --release --bin humpback-dds
'';
installPhase = ''
mkdir -p $out $out/nix-support
cp target/thumbv7em-none-eabihf/release/humpback-dds $out/humpback-dds.elf
echo file binary-dist $out/humpback-dds.elf >> $out/nix-support/hydra-build-products
llvm-objcopy -O binary target/thumbv7em-none-eabihf/release/humpback-dds $out/humpback-dds.bin
echo file binary-dist $out/humpback-dds.bin >> $out/nix-support/hydra-build-products
'';
doCheck = false;
dontFixup = true;
};
in {
packages.x86_64-linux = {
inherit humpback-dds;
};
hydraJobs = {
inherit humpback-dds;
};
devShell.x86_64-linux = pkgs.mkShell {
name = "humpback-dds-dev-shell";
buildInputs = with pkgs; [
rustPlatform.rust.rustc
rustPlatform.rust.cargo
openocd dfu-util
yosys nextpnr icestorm
] ++ (with python3Packages; [
numpy matplotlib migen
]);
};
defaultPackage.x86_64-linux = humpback-dds;
};
}