Update many shas?

In my home.nix, I have a pattern like the below. I’d like to be able to update all extensions to the latest version with minimal hassle. Right now I (1) go to https://marketplace.visualstudio.com/ (2) search package (3) copy new version number and replace last three chars in hash with 000 (4) home-manager switch (5) copy new wanted SHA (6) repeat 4 & 5 for each package. Anyone have a better workflow? This is painfully slow and laborious. update-nix-fetchgit but not sure it’ll work with extensionsFromVscodeMarketplace.

programs.vscode = {
    enable = true;
    extensions = (with pkgs.vscode-extensions; [
      bbenoist.Nix
      ms-python.python
      ms-azuretools.vscode-docker
    ]) ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace
       # https://marketplace.visualstudio.com/
       [
        {
          name = "language-purescript";
          publisher = "nwolverson";
          version = "0.2.1";
          sha256 = "18n35wp55c6k1yr2yrgg2qjmzk0vhz65bygfdk0z2p19pa4qhxzs";
        }
        {
          name = "ide-purescript";
          publisher = "nwolverson";
          version = "0.20.8";
          sha256 = "16avxmb1191l641r6pd99lw2cgq8gdfipb9n7d0czx1g9vfjr3ip";
        }
        {
          name = "bracket-pair-colorizer-2";
          publisher = "CoenraadS";
          version = "0.0.25";
          sha256 = "1v57g9symyqidcsj1cqy43ahi00aw1glbrksh8zd42nsk36cr1yc";
        }
      [...]
2 Likes

Tried my hand at writing a script. Originally idea was to run this with nix-build and use traceSeq. Right now I get an error: error: value is a function while a set was expected. Any tips on how to make this a real script? Although I’ve packaged quite a few things at this point, I’m still clueless when it comes to the nix language. Many thanks!

let
  pkgs = import <nixpkgs>;
  extensions = [
    {
      name = "language-purescript";
      publisher = "nwolverson";
      version = "0.2.1";
      sha256 = "18n35wp55c6k1yr2yrgg2qjmzk0vhz65bygfdk0z2p19pa4qhxzs";
    }
    {
      name = "ide-purescript";
      publisher = "nwolverson";
      version = "0.20.8";
      sha256 = "16avxmb1191l641r6pd99lw2cgq8gdfipb9n7d0czx1g9vfjr3ip";
    }
  ];

  mktplcExtRefToFetchArgs = ext: {
    url = "https://${ext.publisher}.gallery.vsassets.io/_apis/public/gallery/publisher/${ext.publisher}/extension/${ext.name}/${ext.version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage";
    # The `*.vsix` file is in the end a simple zip file. Change the extension
    # so that existing `unzip` hooks takes care of the unpacking.
    name = "${ext.publisher}-${ext.name}.zip";
  };
  fetchVsixFromVscodeMarketplace = mktplcExtRef:
    pkgs.fetchurl((mktplcExtRefToFetchArgs mktplcExtRef));
in
  pkgs.forEach extensions (x: fetchVsixFromVscodeMarketplace)

Maybe you could use niv with its custom URL functionality?

Wow, that’s exactly the type of tool I was looking for, thank you! I’ll check it out

We have https://github.com/NixOS/nixpkgs/blob/42d815d1026e57f7e6f178de5a280c14f7aba1a5/pkgs/misc/vscode-extensions/update_installed_exts.sh. It generates nix expressions for installed vscode extensions that are up to date.

2 Likes

Incredible. I took a stab at updating the wiki: Visual Studio Code - NixOS Wiki

1 Like