summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.default (renamed from test/Makefile)0
-rw-r--r--build.nix30
-rw-r--r--flake.nix13
-rw-r--r--test.nix2
-rw-r--r--ulisp.nix71
5 files changed, 62 insertions, 54 deletions
diff --git a/test/Makefile b/Makefile.default
index 3bf5a70..3bf5a70 100644
--- a/test/Makefile
+++ b/Makefile.default
diff --git a/build.nix b/build.nix
new file mode 100644
index 0000000..3770d57
--- /dev/null
+++ b/build.nix
@@ -0,0 +1,30 @@
+{ pkgs, teensy-core, ... }:
+
+{
+ build = name: source: pkgs.stdenv.mkDerivation rec {
+ inherit name;
+
+ src = source;
+
+ buildInputs = with pkgs; [
+ gcc-arm-embedded
+ teensy-core
+ ];
+
+ buildPhase = ''
+ export CC=arm-none-eabi-gcc
+ export CXX=arm-none-eabi-g++
+ export OBJCOPY=arm-none-eabi-objcopy
+ export SIZE=arm-none-eabi-size
+
+ cp ${./Makefile.default} Makefile
+ export TEENSY_PATH=${teensy-core}
+ make
+ '';
+
+ installPhase = ''
+ mkdir $out
+ cp *.hex $out/
+ '';
+ };
+}
diff --git a/flake.nix b/flake.nix
index 560b5fa..43e8824 100644
--- a/flake.nix
+++ b/flake.nix
@@ -10,8 +10,17 @@
pkgs = import nixpkgs { inherit system; };
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; };
+
+ image = import ./build.nix { inherit pkgs teensy-core; };
+
+ teensy-test = image.build "teensy-test" ./test;
+
+ teensy-ulisp = let
+ ulisp-source = import ./ulisp.nix { inherit pkgs; };
+ in image.build
+ "teensy-ulisp"
+ (pkgs.linkFarmFromDrvs "ulisp" [ ulisp-source ]);
+
in {
packages.${system} = {
inherit teensy-core teensy-test teensy-ulisp;
diff --git a/test.nix b/test.nix
index 8945759..1e26a70 100644
--- a/test.nix
+++ b/test.nix
@@ -16,8 +16,8 @@ pkgs.stdenv.mkDerivation rec {
export OBJCOPY=arm-none-eabi-objcopy
export SIZE=arm-none-eabi-size
+ cp ${teensy-core}/include/Makefile.default Makefile
export TEENSY_PATH=${teensy-core}
-
make
'';
diff --git a/ulisp.nix b/ulisp.nix
index 6fc6e33..b422c58 100644
--- a/ulisp.nix
+++ b/ulisp.nix
@@ -1,65 +1,34 @@
-{ pkgs, teensy-core, ... }:
+{ pkgs, ... }:
-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";
+# hacky usage of arduino-cli to preprocess ulisp "ino" source into compilable C++ code
+pkgs.stdenv.mkDerivation rec {
+ name = "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
- '';
+ src = pkgs.fetchFromGitHub {
+ owner = "technoblogy";
+ repo = "ulisp-arm";
+ rev = "a25fff3ef1072bdc2733d8064fcf0738579ab7ed";
+ sha256 = "p6H9To9vccHrP46Cv5m+cAFDVPXDCORUWcqOz18c3kg=";
};
-in pkgs.stdenv.mkDerivation rec {
- name = "teensy-ulisp";
+ outputHashMode = "flat";
+ outputHashAlgo = "sha256";
+ outputHash = "mutVLBFSpTXgUzu594zZ3akR/Z7e9n5SytU6WoQ6rKA=";
buildInputs = with pkgs; [
- gcc-arm-embedded
- teensy-core
+ cacert
+ arduino-cli
];
- 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
+ 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 = ''
- mkdir $out
- cp *.hex $out/
+ cp ulisp-arm.cpp $out
'';
}