From 5f9537bccc5d177b40c4ea0e902eaf0824786794 Mon Sep 17 00:00:00 2001 From: shimun Date: Fri, 30 Oct 2020 13:58:59 +0100 Subject: [PATCH] build --- default.nix | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..271a979 --- /dev/null +++ b/default.nix @@ -0,0 +1,48 @@ +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/ + ''; +} +