thermostat/default.nix

37 lines
955 B
Nix
Raw Normal View History

2019-03-07 23:27:33 +08:00
let
mozillaOverlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
in
with import <nixpkgs> { overlays = [ mozillaOverlay ]; };
let
rustPlatform = recurseIntoAttrs (callPackage (import ./nix/rustPlatform.nix) {});
2019-03-08 01:24:21 +08:00
adc2tcp = callPackage (import ./nix/adc2tcp.nix) { inherit rustPlatform; };
openocd = callPackage (import ./nix/openocd.nix) {};
2019-03-07 23:27:33 +08:00
in
2019-03-08 01:24:21 +08:00
stdenv.mkDerivation {
name = "adc2tcp-dist";
buildInputs = [
adc2tcp
openocd
gdb
];
src = ./.;
dontBuild = true;
installPhase = ''
mkdir -p $out/bin $out/lib
BIN=$out/lib/adc2tcp
ln -s ${adc2tcp}/lib/adc2tcp $BIN
cat >> $out/bin/flash-adc2tcp <<EOF
#!/usr/bin/env bash
${openocd}/bin/openocd-nucleo-f429zi \
-c "reset halt" \
-c "flash write_image erase $BIN" \
-c "verify_image $BIN" \
-c "reset run" \
-c "shutdown"
EOF
chmod +x $out/bin/flash-adc2tcp
'';
}