Compare commits

...

2 commits

4 changed files with 58 additions and 2 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;
@ -11,4 +11,9 @@ in rec {
inherit target sources; inherit target sources;
inherit (assets) version hosts; inherit (assets) version hosts;
}) assets.toolchains; }) assets.toolchains;
sdk = callPackage ./sdk.nix {
inherit (assets) version hosts;
source = assets.sdk;
};
} }

21
packages/zephyr/sdk.nix Normal file
View file

@ -0,0 +1,21 @@
{ lib, symlinkJoin, fetchurl, zephyr, source, version, hosts, toolchains ? [ ]
}:
let src = fetchurl source;
in symlinkJoin rec {
pname = "zephyr-sdk";
inherit version;
name = "${pname}-${version}";
paths = [ zephyr.host-tools ] ++ toolchains;
postBuild = ''
tar -C "$out" -xf "${src}" --exclude setup.sh --exclude sdk_toolchains --strip-components=1
'';
meta = with lib; {
homepage = "https://www.zephyrproject.org/";
description = "Full Zephyr SDK with customized toolchains";
license = licenses.asl20;
platforms = hosts;
maintainers = with maintainers; [ artemist ];
};
}

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