{ config, pkgs, unstablePkgs, lib, ... }: let 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 ms-vscode.hexeditor ms-vscode-remote.remote-containers ms-vscode-remote.remote-ssh ms-azuretools.vscode-docker github.codespaces # Usability vscodevim.vim waderyan.gitblame mkhl.direnv alefragnani.bookmarks # Dumb AI stuff, for evaluation github.copilot github.copilot-chat continue.continue # Language support ms-vscode.makefile-tools ms-vscode.cpptools ms-vscode.cpptools-extension-pack mesonbuild.mesonbuild ms-python.python ms-python.debugpy charliermarsh.ruff golang.go jnoortheen.nix-ide rust-lang.rust-analyzer haskell.haskell justusadam.language-haskell elixir-lsp.vscode-elixir-ls # Pretty :3 aaron-bond.better-comments catppuccin.catppuccin-vsc-icons catppuccin.catppuccin-vsc jdinhlife.gruvbox ]; externalExtensions = with pkgs.open-vsx; [ # Extensions that aren't included in nixpkgs espressif.esp-idf-extension geequlim.godot-tools miguelsolorio.fluent-icons tonybaloney.vscode-pets ]; newVendorExtensions = with pkgs.vscode-marketplace; [ # Quick editing and viewing of ad-hoc repos and pull request ms-vscode.remote-repositories github.remotehub # Extra extension for PlatformIO tools platformio.platformio-ide ]; 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} # for some reason the tools script likes doubling up # the tools folder, fix that. substituteInPlace $out/tools/idf_tools.py \ --replace-fail \ "os.path.join(g.idf_tools_path, 'tools'," \ "os.path.join(g.idf_tools_path," ''; }); settings = import ./../../configs/vscode/settings.nix { inherit pkgs lib esp-idf; }; keybindings = import ./../../configs/vscode/keybindings.nix { }; in { programs.vscode = { enable = true; package = unstablePkgs.vscodium-fhs; mutableExtensionsDir = false; profiles.default = { enableUpdateCheck = false; enableExtensionUpdateCheck = false; extensions = extensions ++ externalExtensions ++ newVendorExtensions; keybindings = keybindings; userSettings = settings; }; }; # also make the user-settings file mutable, since most # vscode extensions don't like read-only configuration files. home.file."${config.xdg.configHome}/VSCodium/User/settings.json" = { mutable = true; force = true; }; }