From 572886dce9229b781013230c0ef016db31056c2b Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 11 Oct 2021 21:13:00 +0200 Subject: Enable customization of extra core libraries --- core.nix | 27 +++++++-------------------- extra.nix | 24 ++++++++++++++++++++++++ flake.nix | 12 +++++++++--- 3 files changed, 40 insertions(+), 23 deletions(-) create mode 100644 extra.nix 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 ]); -- cgit v1.2.3