-
Notifications
You must be signed in to change notification settings - Fork 27
Description
I’m setting up a dev shell using the flake attached below. Running west build works fine for “regular” Zephyr applications in this setup. However, when using sysbuild (for example, to integrate MCUboot), the build fails due to Python import errors.
My current understanding is that the initial CMake invocation uses the Python environment passed from west via -DWEST_PYTHON=..., which is the correct environment with all dependencies installed through zephyr-nix. That explains why building “regular” applications works.
With sysbuild, however, a second CMake invocation is spawned for MCUboot without -DWEST_PYTHON=.... As a result, it falls back to using the Python found via PATH. In theory this should also work, but in practice the PATH used there differs from the one I get when running echo $PATH inside the dev shell, and it does not contain the correct Python environment.
Using print-style debugging, I found that PATH is already incorrect in west before the Zephyr build even starts. I suspect this is caused by something in the west wrapper binary that is installed into the Python environment’s bin directory.
As a workaround, invoking west as python -m west ... instead of west ... avoids the issue.
flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
zephyr.url = "github:zephyrproject-rtos/zephyr/v4.3.0";
zephyr.flake = false;
zephyr-nix.url = "github:nix-community/zephyr-nix";
zephyr-nix.inputs.nixpkgs.follows = "nixpkgs";
zephyr-nix.inputs.zephyr.follows = "zephyr";
};
outputs = { self, nixpkgs, zephyr-nix, ... }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
zephyr = zephyr-nix.packages.x86_64-linux;
in {
devShells.x86_64-linux.default = pkgs.mkShell {
packages = [
(zephyr.sdk-0_17.override {
targets = [
"arm-zephyr-eabi"
];
})
zephyr.pythonEnv
zephyr.hosttools-nix
pkgs.cmake
pkgs.ninja
];
};
};
}