summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2021-10-10 14:22:31 +0200
committerAdrian Kummerlaender2021-10-10 14:24:32 +0200
commit59918fa4f925c063c8beec7142f786eda5746cc4 (patch)
tree6e204f5d606fa058b0b8ce50d9e8af4bde0e3918
parentc5ccf598a6e23909dead9ac8b413fb42925ee5f4 (diff)
downloadteensy-env-59918fa4f925c063c8beec7142f786eda5746cc4.tar
teensy-env-59918fa4f925c063c8beec7142f786eda5746cc4.tar.gz
teensy-env-59918fa4f925c063c8beec7142f786eda5746cc4.tar.bz2
teensy-env-59918fa4f925c063c8beec7142f786eda5746cc4.tar.lz
teensy-env-59918fa4f925c063c8beec7142f786eda5746cc4.tar.xz
teensy-env-59918fa4f925c063c8beec7142f786eda5746cc4.tar.zst
teensy-env-59918fa4f925c063c8beec7142f786eda5746cc4.zip
Add ulisp-arm derivation
-rw-r--r--core.nix22
-rw-r--r--flake.nix7
-rw-r--r--ulisp.nix65
3 files changed, 90 insertions, 4 deletions
diff --git a/core.nix b/core.nix
index fba64e7..8d2575e 100644
--- a/core.nix
+++ b/core.nix
@@ -1,6 +1,21 @@
{ pkgs, ... }:
-pkgs.stdenvNoCC.mkDerivation rec {
+let
+ spi = pkgs.fetchFromGitHub {
+ owner = "PaulStoffregen";
+ repo = "SPI";
+ rev = "574ab8c7a8a45ea21cc56dcc6b7361da90868e86";
+ sha256 = "I3M7w9SNEXvPD0ynuZ38bnTaenGEORg72E5YC2x6ek4=";
+ };
+
+ wire = pkgs.fetchFromGitHub {
+ owner = "PaulStoffregen";
+ repo = "Wire";
+ rev = "15018075857fa0176d8a5fc610fc564427282ca0";
+ sha256 = "GTfqmQykFS4nXXPBhQHe2gpEUY2sH0ESHh28ZrIW/dE=";
+ };
+
+in pkgs.stdenvNoCC.mkDerivation rec {
name = "teensy-core";
version = "1.54";
@@ -27,8 +42,13 @@ pkgs.stdenvNoCC.mkDerivation rec {
--subst-var-by TEENSY_INCLUDE . \
--subst-var-by TEENSY_LIB .
cp ${./flags.mk} flags.mk
+
+ cp ${spi}/*.{cpp,h} .
+ cp ${wire}/*.{cpp,h} .
+
make
ar rvs libteensy-core.a *.o
+
popd
'';
diff --git a/flake.nix b/flake.nix
index 03109f4..560b5fa 100644
--- a/flake.nix
+++ b/flake.nix
@@ -9,11 +9,12 @@
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
- teensy-core = import ./core.nix { inherit pkgs; };
- teensy-test = import ./test.nix { inherit pkgs teensy-core; };
+ teensy-core = import ./core.nix { inherit pkgs; };
+ teensy-test = import ./test.nix { inherit pkgs teensy-core; };
+ teensy-ulisp = import ./ulisp.nix { inherit pkgs teensy-core; };
in {
packages.${system} = {
- inherit teensy-core teensy-test;
+ inherit teensy-core teensy-test teensy-ulisp;
};
};
}
diff --git a/ulisp.nix b/ulisp.nix
new file mode 100644
index 0000000..6fc6e33
--- /dev/null
+++ b/ulisp.nix
@@ -0,0 +1,65 @@
+{ pkgs, teensy-core, ... }:
+
+let
+ # hacky usage of arduino-cli to preprocess ulisp "ino" source into compilable C++ code
+ preprocessed-ulisp-arm = pkgs.stdenv.mkDerivation rec {
+ name = "preprocessed-ulisp-arm.cpp";
+
+ src = pkgs.fetchFromGitHub {
+ owner = "technoblogy";
+ repo = "ulisp-arm";
+ rev = "a25fff3ef1072bdc2733d8064fcf0738579ab7ed";
+ sha256 = "p6H9To9vccHrP46Cv5m+cAFDVPXDCORUWcqOz18c3kg=";
+ };
+
+ outputHashMode = "flat";
+ outputHashAlgo = "sha256";
+ outputHash = "mutVLBFSpTXgUzu594zZ3akR/Z7e9n5SytU6WoQ6rKA=";
+
+ buildInputs = with pkgs; [
+ cacert
+ arduino-cli
+ ];
+
+ buildPhase = ''
+ export HOME=/tmp/arduino
+ arduino-cli core install arduino:samd
+ mv ulisp-arm.ino source.ino
+ arduino-cli compile --fqbn arduino:samd:arduino_zero_native --preprocess > ulisp-arm.cpp
+ echo 'extern "C" int main(void) { setup(); while(true) { loop(); } }' >> ulisp-arm.cpp
+ '';
+
+ installPhase = ''
+ cp ulisp-arm.cpp $out
+ '';
+ };
+
+in pkgs.stdenv.mkDerivation rec {
+ name = "teensy-ulisp";
+
+ buildInputs = with pkgs; [
+ gcc-arm-embedded
+ teensy-core
+ ];
+
+ phases = [ "buildPhase" "installPhase" ];
+
+ buildPhase = ''
+ cp ${./test/Makefile} Makefile
+ cp ${preprocessed-ulisp-arm} ulisp-arm.cpp
+
+ export CC=arm-none-eabi-gcc
+ export CXX=arm-none-eabi-g++
+ export OBJCOPY=arm-none-eabi-objcopy
+ export SIZE=arm-none-eabi-size
+
+ export TEENSY_PATH=${teensy-core}
+
+ make
+ '';
+
+ installPhase = ''
+ mkdir $out
+ cp *.hex $out/
+ '';
+}