diff options
| -rw-r--r-- | configs/vscode/settings.nix | 10 | ||||
| -rw-r--r-- | modules/home/code.nix | 40 |
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 = { |
