thermostat/default.nix

45 lines
1.2 KiB
Nix
Raw Normal View History

{ # Use master branch of the overlay by default
mozillaOverlay ? import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz),
2019-03-20 05:12:28 +08:00
rustManifest ? builtins.fetchurl "https://static.rust-lang.org/dist/channel-rust-nightly.toml"
}:
let
pkgs = import <nixpkgs> { overlays = [ mozillaOverlay ]; };
in
2019-03-20 02:27:54 +08:00
with pkgs;
2019-03-07 23:27:33 +08:00
let
2019-03-22 20:34:32 +08:00
rustPlatform = recurseIntoAttrs (callPackage ./nix/rustPlatform.nix {
2019-03-20 05:12:28 +08:00
inherit rustManifest;
});
2019-03-22 20:34:32 +08:00
adc2tcp = callPackage ./nix/adc2tcp.nix { inherit rustPlatform; };
openocd = callPackage ./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
];
src = ./.;
dontBuild = true;
installPhase = ''
mkdir -p $out/bin $out/lib $out/nix-support
2019-03-08 01:24:21 +08:00
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
echo file binary-dist $BIN >> $out/nix-support/hydra-build-products
2019-03-08 01:24:21 +08:00
'';
}