Skip to content

Instantly share code, notes, and snippets.

@PleahMaCaka
Last active June 24, 2025 01:22
Show Gist options
  • Save PleahMaCaka/99d87e25d1b509282cf398c16f827fec to your computer and use it in GitHub Desktop.
Save PleahMaCaka/99d87e25d1b509282cf398c16f827fec to your computer and use it in GitHub Desktop.
Zephyr Nix Flake
{
description = "devshell for zephyr";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
zephyr = {
url = "github:zephyrproject-rtos/zephyr/v4.1.0";
flake = false;
};
zephyr-nix.url = "github:adisbladis/zephyr-nix";
zephyr-nix.inputs.nixpkgs.follows = "nixpkgs";
zephyr-nix.inputs.zephyr.follows = "zephyr";
};
nixConfig = {
bash-prompt = "zephyr-devshell";
bash-prompt-suffix = " > ";
};
outputs = { nixpkgs, flake-utils, zephyr-nix, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
zn = zephyr-nix.packages.${system};
in
{
devShells.default = pkgs.mkShell {
name = "zephyr-devshell";
packages = with pkgs; [
# Requirements
coreutils
nix
just
python313
python312Packages.west
python312Packages.pyelftools
python312Packages.packaging
python312Packages.pyyaml
# Optional tools
tio # for access the shell
];
shellHook = ''
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR=${zn.sdkFull}
export PATH=$ZEPHYR_SDK_INSTALL_DIR/arm-zephyr-eabi/bin:$PATH
'';
};
}
);
}
default:
just --list
board := "nucleo_f411re"
device := "ttyACM0"
init:
west init -l ftlib
west update
shell:
tio /dev/{{device}}
build:
west build ftlib -b {{board}}
build-clean:
west build ftlib -b {{board}} --pristine
flash: build
west flash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment