62 lines
1.5 KiB
Nix
62 lines
1.5 KiB
Nix
let
|
|
mozillaOverlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
|
|
pkgs = import <nixpkgs> {overlays = [mozillaOverlay];};
|
|
in with pkgs;
|
|
let
|
|
migen = callPackage ./nix/migen.nix {};
|
|
openocd = callPackage ./nix/openocd.nix {};
|
|
rustPlatform = callPackage ./nix/rustPlatform.nix {};
|
|
itm = callPackage ./nix/itm.nix {inherit rustPlatform;};
|
|
|
|
runOpenOcd = writeShellScriptBin "run-openocd" ''
|
|
openocd \
|
|
-f openocd/openocd.cfg \
|
|
-c init &
|
|
sleep 1
|
|
'';
|
|
|
|
runOpenOcdBlock = writeShellScriptBin "run-openocd-block" ''
|
|
openocd -f openocd/openocd.cfg
|
|
'';
|
|
|
|
setGDBConfigFile = writeShellScriptBin "set-gdb-config-file" ''
|
|
if [[ $1 == "" ]]
|
|
then
|
|
sed -i "2s/.*/runner = \"gdb -q -x gdb_config\/openocd.gdb\"/" .cargo/config
|
|
echo "GDB config file: openocd.gdb"
|
|
else
|
|
sed -i "2s/.*/runner = \"gdb -q -x gdb_config\/$1.gdb\"/" .cargo/config
|
|
echo "GDB config file: $1.gdb"
|
|
fi
|
|
'';
|
|
|
|
openocdFlash = writeShellScriptBin "openocd-flash" ''
|
|
openocd -f openocd/openocd.cfg -f openocd/$1.cfg
|
|
'';
|
|
|
|
publishMqtt = writeShellScriptBin "publish-mqtt" ''
|
|
mosquitto_pub -h localhost -t $1 -m "$2" -d
|
|
'';
|
|
|
|
in
|
|
stdenv.mkDerivation {
|
|
name = "nix-shell";
|
|
buildInputs = with rustPlatform.rust; [
|
|
(pkgs.python3.withPackages(ps: [ migen ]))
|
|
pkgs.yosys
|
|
pkgs.nextpnr
|
|
pkgs.icestorm
|
|
pkgs.gdb
|
|
pkgs.mosquitto
|
|
openocd
|
|
rustc
|
|
cargo
|
|
itm
|
|
runOpenOcd
|
|
runOpenOcdBlock
|
|
setGDBConfigFile
|
|
openocdFlash
|
|
publishMqtt
|
|
];
|
|
}
|