Trivial network-controlled plugs
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.
 
 
 
 

47 lines
1.3 KiB

{ # Use master branch of the overlay by default
mozillaOverlay ? import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz),
rustManifest ? builtins.fetchurl "https://static.rust-lang.org/dist/channel-rust-nightly.toml"
}:
let
pkgs = import <nixpkgs> { overlays = [ mozillaOverlay ]; };
in
with pkgs;
let
rustPlatform = recurseIntoAttrs (callPackage ./nix/rustPlatform.nix {
inherit rustManifest;
});
tnetplug = callPackage ./nix/tnetplug.nix { inherit rustPlatform; };
openocd = callPackage ./nix/openocd.nix {};
in
stdenv.mkDerivation {
name = "tnetplug-dist";
buildInputs = [
tnetplug
openocd
makeWrapper
];
src = ./.;
dontBuild = true;
installPhase =
let
firmwareBinary = "$out/lib/tnetplug.elf";
openOcdFlags = [
"-c" "reset halt"
"-c" "flash write_image erase ${firmwareBinary}"
"-c" "verify_image ${firmwareBinary}"
"-c" "reset run"
"-c" "shutdown"
];
in ''
mkdir -p $out/bin $out/lib $out/nix-support
ln -s ${tnetplug}/lib/tnetplug ${firmwareBinary}
makeWrapper ${openocd}/bin/openocd-nucleo-f429zi $out/bin/flash-tnetplug \
--add-flags "${lib.escapeShellArgs openOcdFlags}"
echo file binary-dist ${firmwareBinary} >> $out/nix-support/hydra-build-products
'';
}