VSCode Raspberry Pi Pico Extension

I’ve been trying to get the Raspberry Pi Pico extension to work on VSCode (which I manage with Home Manager and nix-vscode-extensions) but I’ve just been running into issue after issue.

First, the extension couldn’t even start because one of the extension’s dependencies couldn’t find a shared library despite enabling nix-ld so I had to vibe code a local patch for that. I also set these extension settings to make the extension start and to make the CMake extension work:

"cmake.cmakePath" = "${pkgs.cmake}/bin/cmake";
"raspberry-pi-pico.python3Path" = "${pkgs.python3}/bin/python";

After that I set:

sessionVariables.PICO_SDK_PATH = "${
  pkgs.pico-sdk.override {
    withSubmodules = true;
  }
}/lib/pico-sdk";

in my configuration to tell the extension to use the nixpkgs version of the Pico SDK because the extension itself does not have a setting for the Pico SDK path and setting the environment variable is what the documentation says to do (I could set it in a shell.nix but I work on a team with people who don’t use nix do I don’t want to pollute the project repos with nix-specific files so I set it as a global environment variable instead). Except it seems like the Pico extension doesn’t respect that environment variable because it just downloads another version of the SDK to ~/.pico-sdk anyway. Yet despite downloading its own SDK it still doesn’t work because whenever it tries to create a new project it fails with:

[error] Error: EACCES: permission denied, copyfile '/home/tsundoiii/.vscode/extensions/raspberry-pi.raspberry-pi-pico/scripts/pico-vscode.cmake' -> '/home/tsundoiii/.pico-sdk/cmake/pico-vscode.cmake'
	at copyFileSync (node:fs:3121:11)
	at func (node:electron/js2c/node_init:2:2625)
	at downloadAndInstallSDK (/nix/store/6vcy6zhsbzq8i9n6s1mn25z3kbmgl1hz-vscode-extension-raspberry-pi-raspberry-pi-pico-0.20.1/share/vscode/extensions/raspberry-pi.raspberry-pi-pico/dist/extension.js:16532:53)
	at async /nix/store/6vcy6zhsbzq8i9n6s1mn25z3kbmgl1hz-vscode-extension-raspberry-pi-raspberry-pi-pico-0.20.1/share/vscode/extensions/raspberry-pi.raspberry-pi-pico/dist/extension.js:27219:32

For some reason it can’t access the directory it just created so I had to chmod +w ~/.pico-sdk -R to fix that. After that, creating a new project and building it works, and I can also import an existing project, but when I do that the extension still has the buttons for building and deploying greyed out like the project was never imported.

It just feels like I’m doing something wrong here. Is there really not a better way to do this? So far I have been using nix shells for development similar to this and it has worked, but I would rather get the extension to work so I can click a button to deploy code to a Pico rather than running two terminal commands each time I want to do that.