summary refs log tree commit diff
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2025-02-10 21:59:19 +0100
committerMel <einebeere@gmail.com>2025-02-10 21:59:19 +0100
commit04de433a0da70a070d6c7c483e6f99a7fd42b3b7 (patch)
tree6d24c598e295373167fdece555747279a8898179
parent6ee431a5fa23f240e232eb7dc78f72c8372d5422 (diff)
downloadminerals-04de433a0da70a070d6c7c483e6f99a7fd42b3b7.tar.zst
minerals-04de433a0da70a070d6c7c483e6f99a7fd42b3b7.zip
Add modified ESP-IDF package configuration to VSCodium
Signed-off-by: Mel <einebeere@gmail.com>
-rw-r--r--configs/vscode/settings.nix10
-rw-r--r--modules/home/code.nix40
2 files changed, 47 insertions, 3 deletions
diff --git a/configs/vscode/settings.nix b/configs/vscode/settings.nix
index 4e2fba1..732aab8 100644
--- a/configs/vscode/settings.nix
+++ b/configs/vscode/settings.nix
@@ -1,4 +1,4 @@
-{ pkgs, lib, ... }:
+{ pkgs, lib, esp-idf, ... }:
 
 let
   inherit (lib) getExe;
@@ -66,6 +66,14 @@ in
     dlv = getExe delve;
   };
 
+  # development environment tools configuration
+  "idf.espIdfPath" = "${esp-idf}";
+  "idf.toolsPath" = "${esp-idf}/tools";
+  "idf.gitPath" = getExe pkgs.git;
+  "idf.pythonInstallPath" = "${esp-idf}/python-env/bin/python";
+  "idf.showOnboardingOnInit" = false;
+  "idf.hasWalkthroughBeenShown" = true;
+
   # vscode+vim configuration
   "vim.useSystemClipboard" = true;
   "vim.easymotion" = true;
diff --git a/modules/home/code.nix b/modules/home/code.nix
index e736c11..5513f12 100644
--- a/modules/home/code.nix
+++ b/modules/home/code.nix
@@ -7,8 +7,18 @@
 }:
 
 let
-  settings = import ./../../configs/vscode/settings.nix { inherit pkgs lib; };
-  keybindings = import ./../../configs/vscode/keybindings.nix { };
+  inherit (lib)
+    elem
+    head
+    range
+    versions
+    removePrefix
+    stringAsChars
+    ;
+
+  # filters characters from string `s` according to funciton `f`.
+  # NOTE: this could probably be a util.
+  filterString = f: s: stringAsChars (c: if f c then c else "") s;
 
   extensions = with unstablePkgs.vscode-extensions; [
     # Microsoft vendor extensions
@@ -58,6 +68,32 @@ let
     ms-vscode.remote-repositories
     github.remotehub
   ];
+
+  inherit (pkgs) esp-idf-full;
+  esp-idf-python-env = head esp-idf-full.propagatedBuildInputs;
+
+  digits = map toString (range 0 9);
+  filterVersionString = v: filterString (c: elem c digits || c == ".") v;
+  mkVersion = v: versions.majorMinor (filterVersionString v);
+
+  # the ESP-IDF extension for VSCode for some reason
+  # really wants a python environment under this path in `tools/`...
+  espIdfV = mkVersion esp-idf-full.version;
+  pyEnvV = mkVersion (removePrefix "python3" esp-idf-python-env.name);
+  pythonEnvFolderName = "idf${espIdfV}_py${pyEnvV}_env";
+
+  esp-idf = esp-idf-full.overrideAttrs (attrs: {
+    installPhase =
+      (attrs.installPhase or "")
+      + ''
+        mkdir -p $out/tools/python_env
+        ln -s ${esp-idf-python-env} $out/tools/python_env/${pythonEnvFolderName}
+      '';
+  });
+
+  settings = import ./../../configs/vscode/settings.nix { inherit pkgs lib esp-idf; };
+  keybindings = import ./../../configs/vscode/keybindings.nix { };
+
 in
 {
   programs.vscode = {