Confused about how VSCode extensions versioning works in NixOS

I’m managed to install the haskell.haskell extension through my configuration.nix file (I know this probably should be a user, not system wide thing but I’m not up to splitting the config like that yet).

However, it’s at version 1.7.1, whereas the current version is 1.8.

This leads me to a few questions:

  1. How do I get nix to install the latest version?
  2. How is it okay to even specify an extension without a version? Isn’t NixOS about reproducibility? Or is there a “version” of NixOS I’m using, and that “snapshot” (for want of a better word) explicitly lists extension versions? Can I “update” that snapshot to get newer extension versions?
  3. Can I specify the version of an extensions without going through the details like listing the SHA256 hash of it etc?

I assume you are using the channel approach to manage your system, which provides only limited reproducibility on its own.

A channel does indeed point to a “snapshot” of nixpkgs, which fixes all of its contents to certain revisions/versions.

You can update that snapshot by using nix-channel --update, which you might need to run as root to update the correct set of channels.

Sadly there is no built-in way to Tel the channel to use a certain snapshot. It’s either the one that was set during last update, or the most recent one when you update the next time.

You can pull directly from the VSCode Marketplace with pkgs.vscode-utils.extensionsFromVscodeMarketplace (see e.g. https://github.com/Smaug123/nix-dotfiles/blob/2463b3275b1dfb89137bd39ace6c6defa7a28e30/vscode-extensions.nix#L11 used in https://github.com/Smaug123/nix-dotfiles/blob/2463b3275b1dfb89137bd39ace6c6defa7a28e30/home.nix#L63). You still need to get the SHA right though (I usually do this by just setting the SHA to some nonsense value and then letting darwin-rebuild switch fail and tell me what it actually got).

Would that approach also work if I want to preinstall the extensions in code-server?

It’s been on my very long to-do list, to try and make this more similar to vimPlugins, in which we can just have a top-level registry of extension names. And then just have some update logic to generate the latest of each.

2 Likes
  1. This could be a number of different things
    1. (as mentioned) You may need to update your channel
    2. (as mentioned) Switch to a different install method that isn’t using the nixpkgs package
    3. If it’s outdated at the source, create a PR to update the package or create an issue in nixpkgs requesting the package be updated
  2. You don’t know it but you’re using a specific revision of nixpkgs already, and all packages are at a specific version in that revision
  3. Don’t think specifically what you’re asking is possible, as you mentioned reproducibility and all