Getting VS Code with Extensions Installed (Unstable Repo)
Some extensions may or may not work right on NixOS unless they are done via the NixOS way. The following is kind of a hack to keep the main NixOS running regular channel, but Visual Studio Code from the unstable branch:
Create a vscode.nix
in your /etc/nixos/
folder with the following:
In your imports
area of the main /etc/nixos/configuration.nix
, add ./vscode.nix
.
Add the following to your configuration.nix
file (changing <username>
to your username), this will install your extensions in the local vscode extensions folder (also note that I have the Nix extension and wakatime extensions installing using built-in extensions from Nix, remove if you do not want them):
In a lot of cases, NixOS may give you problems with some lesser known extensions (will get undefined variable errors). A couple extensions have their own .nix files that help to get more problematic extensions installed like Wakatime
or the cpptools
extension. You can check here to see a list of ones you may want to specify as I did in the above example.
To have other extensions that are not already being installed from my previous example, we need to give it four pieces of information for each extension. The best way to do this is to install your extensions the normal way in vscode
and then execute this command from their github. This will give us a list of the extensions and the related information it needs in the format it needs. So now we can adapt the previous code block by giving it more information, in this case we added some eslint
and an elixir language server
extensions to illustrate adding new extensions:
To get updated versions and sha256 keys, you will need to run the same script from github as before. Replace the changed/update extensions. As you would with doing any other changes to the configuration.nix
file, you will need to run the nixos-rebuild
command to have to install vscode
and the extensions you defined.