zephyr-nix/README.md

95 lines
1.6 KiB
Markdown
Raw Normal View History

2024-02-06 02:52:10 +00:00
# zephyr-nix
Develop Zephyr projects using Nix
2024-02-06 04:00:42 +00:00
## Features
2024-02-06 06:25:00 +00:00
* SDK packaging
* `sdk`
The minimal SDK.
Can be overriden with additional targets.
``` nix
sdk.override {
targets = [
"arm-zephyr-eabi"
];
}
```
* `sdkFull`
SDK with all targets enabled.
* Host tools packaging
* `hosttools`
Binary `hosttools` from the Zephyr SDK.
Because of libc incompatibilities not all binaries in this derivation actually works.
* `hosttools-nix`
A re-packaging of the Zephyr SDK hosttools using nixpkgs packages.
2024-02-06 04:00:42 +00:00
## Basic usage
- `shell.nix`
``` nix
{ mkShell
, zephyr
, callPackage
, cmake
, ninja
, lib
}:
mkShell {
packages = [
zephyr.pythonEnv
# Use zephyr.hosttools-nix to use nixpkgs built tooling instead of official Zephyr binaries
zephyr.hosttools
cmake
ninja
];
2024-02-06 06:25:00 +00:00
env.ZEPHYR_SDK_INSTALL_DIR = zephyr.sdk.override {
targets = [
2024-02-06 04:00:42 +00:00
"arm-zephyr-eabi"
];
2024-02-06 06:25:00 +00:00
};
2024-02-06 04:00:42 +00:00
}
```
## Flakes usage
- `flake.nix`
``` nix
{
description = "A very basic Zephyr flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# Customize the version of Zephyr used by the flake here
zephyr.url = "github:zephyrproject-rtos/zephyr/v3.5.0";
zephyr.flake = false;
zephyr-nix.url = "github:adisbladis/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 {
devShell.x86_64-linux.default = pkgs.mkShell {
# Use the same mkShell as documented above
};
};
}
```