From adfa8f8a6e360304801966c0c3e0922a5c76f4b5 Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Sun, 12 Nov 2023 05:10:09 +0000 Subject: [PATCH] Add zephyr dev shell --- flake.nix | 8 +++++++- packages/zephyr/default.nix | 3 +-- packages/zephyr/sdk.nix | 6 +++--- shells/zephyr/default.nix | 24 ++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 shells/zephyr/default.nix diff --git a/flake.nix b/flake.nix index 53e6f9a..f7baba9 100644 --- a/flake.nix +++ b/flake.nix @@ -8,10 +8,16 @@ outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system: - let pkgs = import nixpkgs { inherit system; }; + let + pkgs = import nixpkgs { + inherit system; + overlays = [ (final: prev: self.packages."${system}") ]; + }; in { packages = { zephyr = pkgs.callPackage ./packages/zephyr { }; }; + devShells = { zephyr = pkgs.callPackage ./shells/zephyr { }; }; + formatter = pkgs.nixfmt; }); } diff --git a/packages/zephyr/default.nix b/packages/zephyr/default.nix index 0b4d7f5..238b1dc 100644 --- a/packages/zephyr/default.nix +++ b/packages/zephyr/default.nix @@ -1,6 +1,6 @@ { callPackage, stdenv, lib }: let assets = lib.importJSON ./assets.json; -in rec { +in { host-tools = callPackage ./host-tools.nix { inherit (assets) version hosts; sources = assets.host_tools; @@ -13,7 +13,6 @@ in rec { }) assets.toolchains; sdk = callPackage ./sdk.nix { - inherit host-tools; inherit (assets) version hosts; source = assets.sdk; }; diff --git a/packages/zephyr/sdk.nix b/packages/zephyr/sdk.nix index 43105cd..e18322b 100644 --- a/packages/zephyr/sdk.nix +++ b/packages/zephyr/sdk.nix @@ -1,12 +1,12 @@ -{ lib, symlinkJoin, fetchurl, host-tools, source, version, hosts -, toolchains ? [ ] }: +{ lib, symlinkJoin, fetchurl, zephyr, source, version, hosts, toolchains ? [ ] +}: let src = fetchurl source; in symlinkJoin rec { pname = "zephyr-sdk"; inherit version; name = "${pname}-${version}"; - paths = [ host-tools ] ++ toolchains; + paths = [ zephyr.host-tools ] ++ toolchains; postBuild = '' tar -C "$out" -xf "${src}" --exclude setup.sh --exclude sdk_toolchains --strip-components=1 ''; diff --git a/shells/zephyr/default.nix b/shells/zephyr/default.nix new file mode 100644 index 0000000..b5aa6b3 --- /dev/null +++ b/shells/zephyr/default.nix @@ -0,0 +1,24 @@ +{ mkShell, zephyr, cmake, ninja, gnumake, python3 +, toolchains ? with zephyr.toolchains; [ arm-zephyr-eabi ] }: +let zephyr-sdk = zephyr.sdk.override { inherit toolchains; }; +in mkShell { + packages = [ cmake ninja gnumake python3 ] ++ (with python3.pkgs; [ + # requirements-base.txt + pyelftools + pyyaml + pykwalify + canopen + packaging + progress + psutil + pylink-square + pyserial + requests + anytree + intelhex + west + ]); + + ZEPHYR_TOOLCHAIN_VARIANT = "zephyr"; + ZEPHYR_SDK_INSTALL_DIR = "${zephyr-sdk}"; +}