Add zephyr dev shell

This commit is contained in:
Artemis Tosini 2023-11-12 05:10:09 +00:00
parent f728872208
commit adfa8f8a6e
Signed by: artemist
GPG key ID: ADFFE553DCBB831E
4 changed files with 35 additions and 6 deletions

View file

@ -8,10 +8,16 @@
outputs = { self, nixpkgs, utils }: outputs = { self, nixpkgs, utils }:
utils.lib.eachDefaultSystem (system: utils.lib.eachDefaultSystem (system:
let pkgs = import nixpkgs { inherit system; }; let
pkgs = import nixpkgs {
inherit system;
overlays = [ (final: prev: self.packages."${system}") ];
};
in { in {
packages = { zephyr = pkgs.callPackage ./packages/zephyr { }; }; packages = { zephyr = pkgs.callPackage ./packages/zephyr { }; };
devShells = { zephyr = pkgs.callPackage ./shells/zephyr { }; };
formatter = pkgs.nixfmt; formatter = pkgs.nixfmt;
}); });
} }

View file

@ -1,6 +1,6 @@
{ callPackage, stdenv, lib }: { callPackage, stdenv, lib }:
let assets = lib.importJSON ./assets.json; let assets = lib.importJSON ./assets.json;
in rec { in {
host-tools = callPackage ./host-tools.nix { host-tools = callPackage ./host-tools.nix {
inherit (assets) version hosts; inherit (assets) version hosts;
sources = assets.host_tools; sources = assets.host_tools;
@ -13,7 +13,6 @@ in rec {
}) assets.toolchains; }) assets.toolchains;
sdk = callPackage ./sdk.nix { sdk = callPackage ./sdk.nix {
inherit host-tools;
inherit (assets) version hosts; inherit (assets) version hosts;
source = assets.sdk; source = assets.sdk;
}; };

View file

@ -1,12 +1,12 @@
{ lib, symlinkJoin, fetchurl, host-tools, source, version, hosts { lib, symlinkJoin, fetchurl, zephyr, source, version, hosts, toolchains ? [ ]
, toolchains ? [ ] }: }:
let src = fetchurl source; let src = fetchurl source;
in symlinkJoin rec { in symlinkJoin rec {
pname = "zephyr-sdk"; pname = "zephyr-sdk";
inherit version; inherit version;
name = "${pname}-${version}"; name = "${pname}-${version}";
paths = [ host-tools ] ++ toolchains; paths = [ zephyr.host-tools ] ++ toolchains;
postBuild = '' postBuild = ''
tar -C "$out" -xf "${src}" --exclude setup.sh --exclude sdk_toolchains --strip-components=1 tar -C "$out" -xf "${src}" --exclude setup.sh --exclude sdk_toolchains --strip-components=1
''; '';

24
shells/zephyr/default.nix Normal file
View file

@ -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}";
}