From 714012115b22bb1ad3e272baab8310c66a4003a8 Mon Sep 17 00:00:00 2001 From: Sammyalhashe Date: Sun, 1 Nov 2026 21:03:32 -0500 Subject: [PATCH 1/3] build(nix): provide ESP-IDF v6.1 in the dev shell Pulls ESP-IDF v6.1 (toolchains plus its Python env, including esp-idf-sbom) from a fork of mirrexagon/nixpkgs-esp-dev#135 that also fixes Linux builds of the 6.1 gdb, so the shell builds firmware on NixOS and macOS without a separate install. --- flake.lock | 58 ++++++++++++++++++++++++++++++++++++++++++++++++- flake.nix | 36 +++++++++++++++++++++++++----- scripts/test.sh | 2 +- 3 files changed, 88 insertions(+), 8 deletions(-) diff --git a/flake.lock b/flake.lock index d2e9399f..816a45ab 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1789009968, @@ -16,9 +34,47 @@ "type": "github" } }, + "nixpkgs-esp-dev": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1793658140, + "narHash": "sha256-6eb2LBlqeuRdhMYu0I6syPbI33GGg5SnYKLr4shRP90=", + "owner": "Sammyalhashe", + "repo": "nixpkgs-esp-dev", + "rev": "b574e8e501dfa691814c87d4151043eb991d2be9", + "type": "github" + }, + "original": { + "owner": "Sammyalhashe", + "repo": "nixpkgs-esp-dev", + "rev": "b574e8e501dfa691814c87d4151043eb991d2be9", + "type": "github" + } + }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "nixpkgs-esp-dev": "nixpkgs-esp-dev" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 8348862d..6dfe4399 100644 --- a/flake.nix +++ b/flake.nix @@ -3,9 +3,19 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; + # mirrexagon/nixpkgs-esp-dev#135 (ESP-IDF v6.1) plus a libpython3.14 fix for Linux. + nixpkgs-esp-dev = { + url = "github:Sammyalhashe/nixpkgs-esp-dev/b574e8e501dfa691814c87d4151043eb991d2be9"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs }: + outputs = + { + self, + nixpkgs, + nixpkgs-esp-dev, + }: let systems = [ "x86_64-linux" @@ -17,9 +27,20 @@ forAllSystems = nixpkgs.lib.genAttrs systems; in { - devShells = forAllSystems (system: + devShells = forAllSystems ( + system: let - pkgs = import nixpkgs { inherit system; }; + pkgs = import nixpkgs { + inherit system; + overlays = [ nixpkgs-esp-dev.overlays.default ]; + + # The Python library ecdsa is marked as insecure, but we need it for esptool. + # See https://github.com/mirrexagon/nixpkgs-esp-dev/issues/109 + config.permittedInsecurePackages = [ + "python3.13-ecdsa-0.19.1" + "python3.13-ecdsa-0.19.2" + ]; + }; # LLVM 21 is the major ESP-IDF 6.1 ships as esp-clang and the one # scripts/format.sh requires: clang-format's defaults drift between @@ -50,6 +71,8 @@ pkgs.mbedtls pkgs.SDL2 pkgs.pkg-config + # ESP-IDF v6.1 with its toolchains and Python env (incl. esp-idf-sbom). + pkgs.esp-idf-full ]; shellHook = '' @@ -59,9 +82,10 @@ echo " cmake: $(cmake --version | head -1)" echo " make: $(make --version | head -1)" echo " just: $(just --version)" - echo " firmware: install ESP-IDF v6.1 separately" + echo " firmware: ESP-IDF $(cat "$IDF_PATH/version.txt")" ''; }; - }); + } + ); }; - } +} diff --git a/scripts/test.sh b/scripts/test.sh index 3f27726f..b4538d38 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Run all project tests From 84a4f0f0d8c01a7e92c03d051bf3fc14cffb9610 Mon Sep 17 00:00:00 2001 From: Sammyalhashe Date: Tue, 3 Nov 2026 10:11:25 -0500 Subject: [PATCH 2/3] fix(test): make the host tests run in the Nix shell on NixOS - Use /usr/bin/env bash shebangs; NixOS has no /bin/bash. - Disable fortify hardening in the dev shell: it adds glibc's warn_unused_result to posix_memalign, which -Werror rejects. --- flake.nix | 4 ++++ scripts/ci-checks.sh | 2 +- scripts/format.sh | 2 +- scripts/release.sh | 2 +- scripts/sign_release.sh | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 6dfe4399..b6be962c 100644 --- a/flake.nix +++ b/flake.nix @@ -56,6 +56,10 @@ default = mkShell { name = "kern-dev-shell"; + # The host tests build with -Werror, and fortify adds glibc's + # warn_unused_result to calls like posix_memalign that CI never sees. + hardeningDisable = [ "fortify" ]; + buildInputs = [ # clang-format, clang-tidy and clangd, for scripts/format.sh # and the checked-in .clang-tidy / .clangd configs. diff --git a/scripts/ci-checks.sh b/scripts/ci-checks.sh index d8b61ea4..f1ef0302 100755 --- a/scripts/ci-checks.sh +++ b/scripts/ci-checks.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Run all CI checks for a single commit: format, tests, and a wave_4b build. # Invoked from the per-commit CI loop (see .github/workflows/test-each-commit.yml) diff --git a/scripts/format.sh b/scripts/format.sh index 2065925b..2bf72011 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Script to run clang-format on all .c and .h files in project source directories # Covers main/ and first-party components (excludes libwally-core) diff --git a/scripts/release.sh b/scripts/release.sh index 3cc6081e..e22ec825 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" diff --git a/scripts/sign_release.sh b/scripts/sign_release.sh index a268c172..2225d0e0 100755 --- a/scripts/sign_release.sh +++ b/scripts/sign_release.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Kern release signing + packaging — runs on the AIR-GAPPED signing PC. # # For each device staged by release.sh, this script: From 6a383d1962c8608a7b4c169ef64df9bc87f12224 Mon Sep 17 00:00:00 2001 From: Sammyalhashe Date: Wed, 4 Nov 2026 16:24:56 -0500 Subject: [PATCH 3/3] docs(readme): note nix develop now provides ESP-IDF v6.1 --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3c48f35f..def704bd 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,8 @@ only combination that gets autofocus. ## Prerequisites +NOTE: `nix develop` now provides ESP-IDF `v6.1`, its toolchain, Python tools, and the host tools. This means that `nix` users don't need to follow the following instructions and can skip [here](#developing-on-nix), and then follow [build instructions](#build). + Kern targets [ESP-IDF v6.1](https://docs.espressif.com/projects/esp-idf/en/v6.1/esp32p4/get-started/index.html). Install it for the `esp32p4` target: ```bash @@ -49,14 +51,14 @@ git clone --depth 1 --recurse-submodules --shallow-submodules -b v6.1 https://gi . ~/esp/esp-idf/export.sh ``` -For formatting, host tests, and the desktop simulator, Nix users can enter the development shell: +### Developing on nix + +Nix users can enter the development shell: ```bash nix develop ``` -The Nix shell intentionally provides host tools only. Firmware builds still require the separate ESP-IDF v6.1 installation above; `just build` uses an existing `IDF_PATH` or falls back to `~/esp/esp-idf`. - ## Build ### Cloning the Repository