forked from M-Labs/thermostat
default.nix, nix/openocd: replace shell script with makeWrapper
This commit is contained in:
parent
462c5e2668
commit
cbfe3a177b
36
default.nix
36
default.nix
|
@ -19,26 +19,30 @@ stdenv.mkDerivation {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
adc2tcp
|
adc2tcp
|
||||||
openocd
|
openocd
|
||||||
|
makeWrapper
|
||||||
];
|
];
|
||||||
src = ./.;
|
src = ./.;
|
||||||
dontBuild = true;
|
dontBuild = true;
|
||||||
|
|
||||||
installPhase = ''
|
installPhase =
|
||||||
mkdir -p $out/bin $out/lib $out/nix-support
|
let
|
||||||
|
firmwareBinary = "$out/lib/adc2tcp.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
|
||||||
|
|
||||||
BIN=$out/lib/adc2tcp
|
BIN=$out/lib/adc2tcp
|
||||||
ln -s ${adc2tcp}/lib/adc2tcp $BIN
|
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
|
makeWrapper ${openocd}/bin/openocd-nucleo-f429zi $out/bin/flash-adc2tcp \
|
||||||
'';
|
--add-flags "${lib.escapeShellArgs openOcdFlags}"
|
||||||
|
|
||||||
|
echo file binary-dist ${firmwareBinary} >> $out/nix-support/hydra-build-products
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
{ stdenv, openocd }:
|
{ stdenv, lib, openocd, makeWrapper }:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "openocd-nucleo-f429zi";
|
name = "openocd-nucleo-f429zi";
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
openocd
|
openocd
|
||||||
|
makeWrapper
|
||||||
];
|
];
|
||||||
src = ./.;
|
src = ./.;
|
||||||
noBuild = true;
|
noBuild = true;
|
||||||
installPhase = ''
|
installPhase =
|
||||||
mkdir -p $out/bin
|
let
|
||||||
cat >> $out/bin/openocd-nucleo-f429zi <<EOF
|
openOcdFlags = [
|
||||||
#!/usr/bin/env bash
|
"-f" "${openocd}/share/openocd/scripts/interface/stlink-v2-1.cfg"
|
||||||
${openocd}/bin/openocd \
|
"-f" "${openocd}/share/openocd/scripts/target/stm32f4x.cfg"
|
||||||
-f ${openocd}/share/openocd/scripts/interface/stlink-v2-1.cfg \
|
"-c" "init"
|
||||||
-f ${openocd}/share/openocd/scripts/target/stm32f4x.cfg \
|
];
|
||||||
-c "init" \
|
in ''
|
||||||
"\$@"
|
mkdir -p $out/bin
|
||||||
EOF
|
|
||||||
chmod +x $out/bin/openocd-nucleo-f429zi
|
makeWrapper ${openocd}/bin/openocd $out/bin/openocd-nucleo-f429zi \
|
||||||
'';
|
--add-flags "${lib.escapeShellArgs openOcdFlags}"
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue