At the time of writing this, nixpkgs contains 271 VS Code extensions. This is a small fraction of the more than 40,000 extensions in the VS Code Marketplace! In addition, many of the extensions in nixpkgs are significantly out-of-date.
This flake provides Nix expressions for the majority of available extensions from Open VSX and VS Code Marketplace. A GitHub Action updates the extensions daily.
That said, you can now use a different set of extensions for VS Code/VSCodium in each of your projects. Moreover, you can share your flakes and cache them so that other people don't need to install these extensions manually!
- We have a permission from MS to use a crawler on their API (see the discussion). Don't abuse this flake!
- Check nix4vscode (and contribute!) if you need a more individual approach to extensions.
You can search for an extension in the repository history:
- Get commits containing the extension:
git log -S '"copilot"' --oneline data/cache/vscode-marketplace-latest.json - Select a commit, e.g.:
0910d1e - Search in that commit:
git grep '"copilot"' 0910d1e -- data/cache/vscode-marketplace-latest.json
The flake.nix provides an example (packages.${builtins.currentSystem}.default) of vscode-with-extensions.
This package is VS Code with a couple of extensions.
Run VS Code and list installed extensions.
nix run github:nix-community/nix-vscode-extensions/00e11463876a04a77fb97ba50c015ab9e5bee90d# -- --list-extensionsThis repository has a flake template.
This template provides a VSCodium with a couple of extensions.
-
Create a flake from the template (see nix flake new).
nix flake new vscodium-project -t github:nix-community/nix-vscode-extensions cd vscodium-project git init && git add .
-
Run
VSCodium.nix run .# . -
Alternatively, start a devShell and run
VSCodium. AshellHookwill print extensions available in theVSCodium.nix develop .#vscodium codium .
In case of problems see Troubleshooting.
See Overlays.
If you use NixOS, Home Manager, or similar:
-
If you use flakes, add
nix-vscode-extensionsto your flake inputs (see example).inputs.nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions/00e11463876a04a77fb97ba50c015ab9e5bee90d"; outputs = inputs@{ nix-vscode-extensions, ... }: ...
-
If you don't use flakes, import the
nix-vscode-extensionsrepository.let nix-vscode-extensions = import ( builtins.fetchGit { url = "https://github.com/nix-community/nix-vscode-extensions"; ref = "refs/heads/master"; rev = "00e11463876a04a77fb97ba50c015ab9e5bee90d"; } ); in
-
Add the
nix-vscode-extensions.overlays.defaulttonixpkgsoverlays (see Getextensionsvia the overlay, example). -
(Optional) Allow unfree packages (see Unfree extensions).
-
Use
pkgs.vscode-marketplace,pkgs.open-vsxand others (seeextensionsattrsets, example).[!NOTE] See With-expressions.
In
with A; with B;, the attributes ofBshadow the attributes ofA.Keep in mind this property of
withwhen writingwith vscode-marketplace; with vscode-marketplace-release;.
See nix repl.
nix replnix-repl> builtins.currentSystemOutput on my machine:
x86_64-linuxnix-repl> nixpkgs = builtins.getFlake github:nixos/nixpkgs/ebe4301cbd8f81c4f8d3244b3632338bbeb6d49cnix-repl> nixpkgs = (import (builtins.fetchGit {
url = "https://github.com/NixOS/nixpkgs";
ref = "refs/heads/master";
rev = "ebe4301cbd8f81c4f8d3244b3632338bbeb6d49c";
}))nix-repl> nix-vscode-extensions = builtins.getFlake github:nix-community/nix-vscode-extensions/00e11463876a04a77fb97ba50c015ab9e5bee90dnix-repl> nix-vscode-extensions = (import (builtins.fetchGit {
url = "https://github.com/nix-community/nix-vscode-extensions";
ref = "refs/heads/master";
rev = "00e11463876a04a77fb97ba50c015ab9e5bee90d";
}))nix-repl> extensions = import nixpkgs { system = builtins.currentSystem; config.allowUnfree = true; overlays = [ nix-vscode-extensions.overlays.default ]; }If you want extensions to have only extensions attrsets, get extensions as follows:
nix-repl> extensions = (import nixpkgs { system = builtins.currentSystem; config.allowUnfree = true; overlays = [ nix-vscode-extensions.overlays.default ]; }).nix-vscode-extensionsnix-repl> extensions = nix-vscode-extensions.extensions.x86_64-linuxWe provide attrsets that contain both universal and platform-specific extensions.
We use a reasonable mapping between the sites target platforms and Nix-supported platforms (see systemPlatform in flake.nix, issue).
The Get extensions section explains how to get the extensions attrset.
This attrset contains the following attributes:
vscode-marketplaceandopen-vsxcontain the latest versions of extensions, including pre-release ones. Such pre-release versions expire in some time. That's why, there are*-releaseattrsets.vscode-marketplace-releaseandopen-vsx-releasecontain the release versions of extensions (see Release extensions).forVSCodeVersion-forVSCodeVersion "1.78.2"produces an attrset containing only the extensions compatible with the"1.78.2"version ofVS Code(see Versions compatible with a given version of VS Code).- You may supply the actual version of your
VS Codeinstead of"1.78.2".
- You may supply the actual version of your
usingFixesFrom-usingFixesFrom nixpkgsWithFixesproduces an attrset where particular extensions have fixes specified in the suppliednixpkgsWithFixes(seemkExtensionNixpkgsin mkExtension.nix, Versions with fixes from particularnixpkgs).- The supplied
nixpkgsWithFixescan be any version ofnixpkgs(see Getnixpkgs). - The supplied
nixpkgsWithFixesis used only to look up the fixes in its source code and is independent of thenixpkgsthat you apply the overlay to.
- The supplied
- The top-level
vscode-marketplace*andopen-vsx*attributes are constructed using fixes fromnixpkgsthat you apply the overlay to (if you getextensionsvia the overlay) ornixpkgsfrom thenix-vscode-extensionsrepository (if you getextensionsfromnix-vscode-extensions).
- Extension publishers and names are lowercased only in Nix.
- They're not lowercased in
.jsoncache files such as data/cache/open-vsx-latest.json.
- They're not lowercased in
- Access an extension in the format
<attrset>.<publisher>.<name>, where<attrset>isvscode-marketplace,open-vsx, etc. (see Explore). - If an extension publisher or name aren't valid Nix identifiers, quote them like
<attrset>."4"."2".
- Some previously available extensions may be unavailable in newer versions of this flake.
- An extension is missing if it doesn't appear during a particular workflow run in a
VS Code Marketplaceor anOpen VSXresponse about the full set of available extensions (discussion). - We let missing extensions remain in cache files (see data/cache) at most
maxMissingTimes(specified in .github/config.yaml).
- An extension is missing if it doesn't appear during a particular workflow run in a
- We don't automatically handle extension packs. You should look up extensions in a pack and explicitly write all necessary extensions.
-
We use derivations and code from
nixpkgsfor some extensions (see Versions with fixes from particularnixpkgs). -
Unfree extensions from
nixpkgsstay unfree here (see Unfree software, Special extensions). -
If you want to use unfree extensions, try one of the following ways:
-
Set
config.allowUnfree = truewhen constructingpkgs.pkgs = import nixpkgs { system = builtins.currentSystem; config.allowUnfree = true; overlays = [ overlays.default ]; }
-
Override the license of a particular extension.
let resetLicense = drv: drv.overrideAttrs (prev: { meta = prev.meta // { license = [ ]; }; }); in resetLicense <publisher>.<name>
Note
Press the Tab button (denoted as <TAB> below) to see attrset attributes.
nix-repl> extensions.<TAB>
extensions.forVSCodeVersion extensions.usingFixesFrom
extensions.open-vsx extensions.vscode-marketplace
extensions.open-vsx-release extensions.vscode-marketplace-releasenix-repl> extensions.vscode-marketplace.rust-lang.rust-analyzer
«derivation /nix/store/v2dyb61zg6faalpcz4faf6dd0ckgbcsp-vscode-extension-rust-lang-rust-analyzer-0.4.2434.drv»nix-repl> extensions.vscode-marketplace-release.rust-lang.rust-analyzer
«derivation /nix/store/5xhr4a3j62awpnsd9l0llq2yn9q4gb6r-vscode-extension-rust-lang-rust-analyzer-0.3.2433.drv»nix-repl> extensionsCompatible = extensions.forVSCodeVersion "1.78.2"The extensionsCompatible attrset contains some of the extensions attrsets.
Some extensions require non-trivial fixes (example).
These fixes may be available in a particular version of nixpkgs.
These fixes are read from the source code of that nixpkgs version (see mkExtensionNixpkgs in mkExtension.nix).
In this case, we use the same version of nixpkgs that was used to get extensions.
You can use any other version instead.
nix-repl> extensionsFixed = extensions.usingFixesFrom nixpkgsThe extensionsFixed attrset contains some of the extensions attrsets.
Some extensions are unavailable or don't work on particular platforms.
These extensions are disabled via removed.nix.
Resolve issues.
- Fix links.
- Write new sections.
- Update commit hashes used in examples if they're too old.
- Enhance text.
The config contains several extensions. We cache the information about the latest release versions of these extensions (see Extensions).
You can add new extensions to the config and make a Pull Request.
Use the original extension publisher and name, e.g. GitHub and copilot.
The extra-extensions.toml file contains a list of extensions to be fetched from sites other than VS Code Marketplace and Open VSX.
These extensions replace ones fetched from VS Code Marketplace and Open VSX.
Add necessary extensions there, preferrably, for all supported platforms (see Extensions).
nvfetcher will fetch the latest release versions of these extensions and write configs to generated.nix.
Certain extensions require special treatment.
Provide functions to build such extension in the extensions directory (see extensions/default.nix).
Optionally, create and link issues explaining chosen functions.
Each extension, including Extra extensions, is built via one of the functions in mkExtension.nix.
These functions don't modify the license of (unfree) extensions from nixpkgs.
-
(Optionally) Install, e.g., via
nix profile install nixpkgs#direnv. -
Run a devshell. When prompted about
extra-trusted-substitutersanswery. This is to use binary caches.nix develop nix-dev/ -
(Optionally) Start
VSCodiumwith necessary extensions and tools.nix run nix-dev/#codium .
-
See the README.
-
Set the environment.
set -a source .env
-
Run the script.
nix run haskell/#updateExtensions
Pull requests are welcome!
- If
Nix-providedVSCodiumdoesn't pick up the extensions:- Close other instances of
Nix-providedVSCodiumand startVSCodiumagain. - Try to reboot your computer and start
VSCodiumagain.
- Close other instances of