From 5ea1fa86ee32d6407a349ef2653d7ad1a7b8001d Mon Sep 17 00:00:00 2001 From: Dom H Date: Sat, 4 Dec 2021 10:56:54 +0000 Subject: [PATCH 1/3] fix(setup): Add zephyr requirements to nix-shell Use mach-nix to handle zephyr's python requirements. --- shell.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/shell.nix b/shell.nix index 145f7115..e34f20c8 100644 --- a/shell.nix +++ b/shell.nix @@ -3,6 +3,15 @@ with pkgs; let inherit (lib) ; + mach-nix = import (builtins.fetchGit { + url = "https://github.com/DavHau/mach-nix"; + ref = "master"; + }) { + python = "python3"; + }; + machNix = mach-nix.mkPython rec { + requirements = builtins.readFile ./zephyr/scripts/requirements-base.txt; + }; in mkShell { buildInputs = [ cmake @@ -11,9 +20,7 @@ in mkShell { dtc dfu-util gcc-arm-embedded - python3 - python38Packages.west - python38Packages.pip + machNix ]; shellHook = '' From baed737e2f8a17f208090aabbffb41e12b923b39 Mon Sep 17 00:00:00 2001 From: Dom H Date: Sun, 16 Jan 2022 18:44:45 +0000 Subject: [PATCH 2/3] fix(setup): Fetch Zephyr requirements from URL The requirements cannot be read from the file in `./zephyr/` because this directory does not yet exist in a clean repo. Fetching the requirements file from an upstream URL is consistent with how the ZMK docker image does it: https://github.com/zmkfirmware/zmk-docker/blob/25972e7aad57a2b48f6141185711943cf76fc03b/Dockerfile#L26-L27 --- shell.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shell.nix b/shell.nix index e34f20c8..f36dc2e2 100644 --- a/shell.nix +++ b/shell.nix @@ -9,8 +9,12 @@ let inherit (lib) ; }) { python = "python3"; }; + zephyr-requirements = fetchurl { + url = "https://raw.githubusercontent.com/zephyrproject-rtos/zephyr/v2.5.0/scripts/requirements-base.txt"; + sha256 = "919a78ba9457a8e55451450329158ff7fdcbc4a2ddb0dd76ea804c3b04a3c6c6"; + }; machNix = mach-nix.mkPython rec { - requirements = builtins.readFile ./zephyr/scripts/requirements-base.txt; + requirements = builtins.readFile zephyr-requirements; }; in mkShell { buildInputs = [ From 8c8c245ba8cf74f0d6efda6272da3441c1abedc8 Mon Sep 17 00:00:00 2001 From: Dom H Date: Mon, 17 Jan 2022 05:20:07 +0000 Subject: [PATCH 3/3] refactor(setup): More descriptive variable name --- shell.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell.nix b/shell.nix index f36dc2e2..db301abf 100644 --- a/shell.nix +++ b/shell.nix @@ -13,7 +13,7 @@ let inherit (lib) ; url = "https://raw.githubusercontent.com/zephyrproject-rtos/zephyr/v2.5.0/scripts/requirements-base.txt"; sha256 = "919a78ba9457a8e55451450329158ff7fdcbc4a2ddb0dd76ea804c3b04a3c6c6"; }; - machNix = mach-nix.mkPython rec { + python-pkgs = mach-nix.mkPython rec { requirements = builtins.readFile zephyr-requirements; }; in mkShell { @@ -24,7 +24,7 @@ in mkShell { dtc dfu-util gcc-arm-embedded - machNix + python-pkgs ]; shellHook = ''