solo/default.nix
2020-10-30 13:58:59 +01:00

49 lines
1.7 KiB
Nix

let
pkgs = import (fetchTarball { url = "https://github.com/NixOS/nixpkgs/archive/20.03.tar.gz"; sha256 = "0182ys095dfx02vl2a20j1hz92dx3mfgz2a6fhn31bqlp1wa8hlq"; }) {};
pyPackages = (python-packages: with python-packages; ([
solo-python pytest
] ++ (with builtins; map (d: getAttr d python-packages) (filter (d: stringLength d > 0) (pkgs.lib.splitString "\n" (builtins.readFile ./tools/requirements.txt))))));
python-with-my-packages = pkgs.python3.withPackages pyPackages;
src = ./.;
tinycbor = with pkgs; stdenv.mkDerivation {
name = "tinycbor";
src = "${src}/tinycbor";
makeFlags = [ "PREFIX=$(out)" "prefix=$(out)" ];
buildInputs = [ gcc gcc-arm-embedded-8 ];
};
standalone = with pkgs; stdenv.mkDerivation {
name = "solo-standalone";
src = [
src
tinycbor
];
buildInputs = [ gnumake gcc gcc-arm-embedded-8 python-with-my-packages ];
installPhase = ''
make clean
make all PREFIX=$(out)" "prefix=$(out)
mkdir -p $out/bin
cp main $out/bin/
'';
};
in
with pkgs; stdenv.mkDerivation {
name = "solo";
outputs = [ "out" "firmware" ];
src = builtins.filterSource (path: type: (!(lib.hasSuffix path "./tinycbor/lib") && !(lib.hasSuffix path ".hex")&& !(lib.hasSuffix path ".sha256")&& !(lib.hasSuffix path ".elf"))) ./.;
buildInputs = [ gnumake gcc gcc-arm-embedded-8 git python-with-my-packages ];
########installPhase = ''
######## mkdir -p $firmware $standalone/bin/
######## cp main $standalone/bin/
######## cd stm32l432
######## make firmware
######## cp *.hex *.sha256 *.elf cubeconfig_stm32l442.ioc $firmware/
########'';
installPhase = ''
cd targets/stm32l432
make cbor
make build-hacker
cp *.hex *.sha256 *.elf cubeconfig_stm32l442.ioc $firmware/
'';
}