summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2021-10-11 21:13:00 +0200
committerAdrian Kummerlaender2021-10-11 21:13:00 +0200
commit572886dce9229b781013230c0ef016db31056c2b (patch)
treeca1d2883b00f122ff326de337c481d124fb387f5
parentac4eb7d7347d41481f08e4ba78339d41f1ebd3d4 (diff)
downloadteensy-env-572886dce9229b781013230c0ef016db31056c2b.tar
teensy-env-572886dce9229b781013230c0ef016db31056c2b.tar.gz
teensy-env-572886dce9229b781013230c0ef016db31056c2b.tar.bz2
teensy-env-572886dce9229b781013230c0ef016db31056c2b.tar.lz
teensy-env-572886dce9229b781013230c0ef016db31056c2b.tar.xz
teensy-env-572886dce9229b781013230c0ef016db31056c2b.tar.zst
teensy-env-572886dce9229b781013230c0ef016db31056c2b.zip
Enable customization of extra core libraries
-rw-r--r--core.nix27
-rw-r--r--extra.nix24
-rw-r--r--flake.nix12
3 files changed, 40 insertions, 23 deletions
diff --git a/core.nix b/core.nix
index 8d2575e..a67e83d 100644
--- a/core.nix
+++ b/core.nix
@@ -1,21 +1,6 @@
-{ pkgs, ... }:
+{ pkgs, libs ? [ ], ... }:
-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 {
+pkgs.stdenvNoCC.mkDerivation rec {
name = "teensy-core";
version = "1.54";
@@ -31,7 +16,10 @@ in pkgs.stdenvNoCC.mkDerivation rec {
gcc-arm-embedded
];
- buildPhase = ''
+ buildPhase = let
+ copyLibs = libs: builtins.concatStringsSep "\n" (map (lib: "cp ${lib}/*.{cpp,h} .") libs);
+
+ in ''
export CC=arm-none-eabi-gcc
export CXX=arm-none-eabi-g++
@@ -43,8 +31,7 @@ in pkgs.stdenvNoCC.mkDerivation rec {
--subst-var-by TEENSY_LIB .
cp ${./flags.mk} flags.mk
- cp ${spi}/*.{cpp,h} .
- cp ${wire}/*.{cpp,h} .
+ ${copyLibs libs}
make
ar rvs libteensy-core.a *.o
diff --git a/extra.nix b/extra.nix
new file mode 100644
index 0000000..40c1678
--- /dev/null
+++ b/extra.nix
@@ -0,0 +1,24 @@
+{ pkgs, ... }:
+
+{
+ spi = pkgs.fetchFromGitHub {
+ owner = "PaulStoffregen";
+ repo = "SPI";
+ rev = "574ab8c7a8a45ea21cc56dcc6b7361da90868e86";
+ sha256 = "I3M7w9SNEXvPD0ynuZ38bnTaenGEORg72E5YC2x6ek4=";
+ };
+
+ wire = pkgs.fetchFromGitHub {
+ owner = "PaulStoffregen";
+ repo = "Wire";
+ rev = "15018075857fa0176d8a5fc610fc564427282ca0";
+ sha256 = "GTfqmQykFS4nXXPBhQHe2gpEUY2sH0ESHh28ZrIW/dE=";
+ };
+
+ servo = pkgs.fetchFromGitHub {
+ owner = "PaulStoffregen";
+ repo = "Servo";
+ rev = "0cf9712f15e1ab175f0ec06496bad1c23453fb64";
+ sha256 = "k6QIWXJmPbLzd9gDmnrwWSA7kcUu7OcWfOwILVAYAbQ=";
+ };
+}
diff --git a/flake.nix b/flake.nix
index b2c2111..eba78cd 100644
--- a/flake.nix
+++ b/flake.nix
@@ -9,15 +9,21 @@
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
- teensy-core = import ./core.nix { inherit pkgs; };
+ teensy-core = import ./core.nix { inherit pkgs; };
+ teensy-extras = import ./extra.nix { inherit pkgs; };
image = import ./build.nix { inherit pkgs teensy-core; };
- teensy-test = image.build "teensy-test" ./test;
+ teensy-test = image.build "teensy-test" ./test;
+
+ imageWith = libs: let
+ teensy-core = import ./core.nix { inherit pkgs libs; };
+ in (import ./build.nix { inherit pkgs teensy-core; });
teensy-ulisp = let
ulisp-source = import ./ulisp.nix { inherit pkgs; };
- in image.build
+ ulisp-deps = with teensy-extras; [ spi wire ];
+ in (imageWith ulisp-deps).build
"teensy-ulisp"
(pkgs.linkFarmFromDrvs "ulisp" [ ulisp-source ]);