nix-vscode-extensions
nix-vscode-extensions copied to clipboard
Nix expressions for VSCode and OpenVSX extensions [maintainers: @deemp, @AmeerTaweel]
Nix expressions for VS Code Extensions
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!
Note
- Check nix4vscode (and contribute!) if you need a more individual approach to extensions.
- NixOS wiki has a page about VS Code.
- Extension publishers and names are lowercased only in Nix.
- They're not lowercased in
.jsoncache files.
- 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". - We have a permission from MS to use a crawler on their API in this case (see the discussion). Please, don't abuse this flake!
Template
This 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 codium .
In case of problems see Troubleshooting.
Example
flake.nix provides a default package.
This package is VSCodium with a couple of extensions.
Run VSCodium and list installed extensions.
nix run github:nix-community/nix-vscode-extensions# -- --list-extensions
Usage
Extensions
We provide extensions attrsets that contain both universal and platform-specific extensions.
We use a reasonable mapping between the sites target platforms and Nix-supported platforms (see the issue and systemPlatform in flake.nix).
There are several attrsets:
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 "4.228.1"allows to leave only the extensions compatible with the"4.228.1"version ofVS Code.- You may supply the actual version of your
VS Codeinstead of"4.228.1".
- You may supply the actual version of your
[!NOTE] In
with A; with B;, the attributes ofBshadow the attributes ofA. Keep in mind this property ofwithwhen writingwith vscode-marketplace; with vscode-marketplace-release;. See With-expressions.
With flakes
See Template.
Add the following to your flake.nix (see Flakes).
inputs.nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions";
Without flakes
let
system = builtins.currentSystem;
extensions =
(import (builtins.fetchGit {
url = "https://github.com/nix-community/nix-vscode-extensions";
ref = "refs/heads/master";
rev = "c43d9089df96cf8aca157762ed0e2ddca9fcd71e";
})).extensions.${system};
extensionsList = with extensions.vscode-marketplace; [
rust-lang.rust-analyzer
];
in ...
History
You can search for an extension in the repo history:
- get commits containing the extension:
git log -S '"copilot"' --oneline data/cache/vscode-marketplace-latest.json - select a commit:
0910d1e - search in that commit:
git grep '"copilot"' 0910d1e -- data/cache/vscode-marketplace-latest.json
Explore
Explore extensions via nix repl.
Use your system instead of x86_64-linux.
Press the Tab button (denoted as <TAB> here) to see attrset attributes.
Get the extensions attrset
Get extensions with flakes
$ nix repl
nix-repl> :lf github:nix-community/nix-vscode-extensions/c43d9089df96cf8aca157762ed0e2ddca9fcd71e
Added 10 variables.
nix-repl> t = extensions.<TAB>
extensions.aarch64-darwin extensions.aarch64-linux extensions.x86_64-darwin extensions.x86_64-linux
nix-repl> t = extensions.x86_64-linux
nix-repl> t.<TAB>
t.forVSCodeVersion t.open-vsx-release t.vscode-marketplace-release
t.open-vsx t.vscode-marketplace
Get extensions without flakes
$ nix repl
nix-repl> t1 = (import (builtins.fetchGit {
url = "https://github.com/nix-community/nix-vscode-extensions";
ref = "refs/heads/master";
rev = "c43d9089df96cf8aca157762ed0e2ddca9fcd71e";
}))
nix-repl> t = t1.extensions.<TAB>
t1.extensions.aarch64-darwin t1.extensions.aarch64-linux t1.extensions.x86_64-darwin t1.extensions.x86_64-linux
nix-repl> t = t1.extensions.x86_64-linux
nix-repl> t.<TAB>
t.forVSCodeVersion t.open-vsx-release t.vscode-marketplace-release
t.open-vsx t.vscode-marketplace
Pre-release versions
nix-repl> t.vscode-marketplace.rust-lang.rust-analyzer
«derivation /nix/store/jyzab0pdcgj4q9l73zsnyvc1k7qpb381-vscode-extension-rust-lang-rust-analyzer-0.4.1582.drv»
Release versions
nix-repl> t.vscode-marketplace-release.rust-lang.rust-analyzer
«derivation /nix/store/qjlr7iqgqrf2hd2z21xz96nmblxy680m-vscode-extension-rust-lang-rust-analyzer-0.3.1583.drv»
Pre-release versions compatible with a given version of VS Code
nix-repl> (t.forVSCodeVersion "1.78.2").vscode-marketplace.rust-lang.rust-analyzer
«derivation /nix/store/jyzab0pdcgj4q9l73zsnyvc1k7qpb381-vscode-extension-rust-lang-rust-analyzer-0.4.1582.drv»
Overlay
See Overlays.
Get an overlay with flakes
nix-repl> :lf github:nix-community/nix-vscode-extensions/c43d9089df96cf8aca157762ed0e2ddca9fcd71e
Added 14 variables.
nix-repl> :lf github:nix-community/nix-vscode-extensions/c43d9089df96cf8aca157762ed0e2ddca9fcd71e
Added 14 variables.
nix-repl> pkgs = (legacyPackages.x86_64-linux.extend overlays.default)
nix-repl> pkgs.vscode-marketplace-release.rust-lang.rust-analyzer
«derivation /nix/store/midv6wrnpxfm3in3miilyx914zzck4d7-vscode-extension-rust-lang-rust-analyzer-0.3.1575.drv»
Get an overlay without flakes
nix-repl> t1 = (import (builtins.fetchGit {
url = "https://github.com/nix-community/nix-vscode-extensions";
ref = "refs/heads/master";
rev = "c43d9089df96cf8aca157762ed0e2ddca9fcd71e";
}))
nix-repl> pkgs = import <nixpkgs> { overlays = [ t1.overlays.default ]; system = builtins.currentSystem; }
nix-repl> pkgs.vscode-marketplace-release.rust-lang.rust-analyzer
«derivation /nix/store/a701wlb8ckidpikr57bff16mmvsf3jir-vscode-extension-rust-lang-rust-analyzer-0.3.1575.drv»
Contribute
Issues
Resolve issues.
README
- Fix links.
- Write new sections.
- Update commit SHA used in examples if they're too old.
- Enhance text.
Release extensions
The config contains several extensions. We cache the information about the latest release versions of these extensions (see Extensions). If you'd like to use release versions of an extension, please, add that extension to the config and make a Pull Request.
Extra extensions
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.
Special extensions
Certain extensions require special treatment. Provide functions to modify such extensions derivations in overrides.nix. Optionally, create and link there issues explaining chosen override functions. The overrides apply to a whole attrset of extensions, including Extra extensions.
Build problems
Main flake
-
(Optionally) Install direnv, 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/#writeSettings nix run nix-dev/#codium .
Haskell script
-
See the README.
-
Set the environment.
set -a source .env -
Run the script.
nix run haskell/#updateExtensions
Pull requests
Pull requests are welcome!
Troubleshooting
- If
Nix-providedVSCodiumdoesn't pick up the extensions:- Close other instance of
Nix-providedVSCodium. - Try to reboot your computer and start
VSCodiumagain.
- Close other instance of
- See troubleshooting.