Vscode fails to build with "attribute vscodeExtUniqueId missing" error

Based on 3588, all extensions need to have vscodeExtUniqueId. But I am not sure how should i modify my code to include this into my extension.

Error:

error: attribute 'vscodeExtUniqueId' missing

       at /nix/store/vwnfcqj0dfz7502smasxi6dl272y7345-source/pkgs/applications/editors/vscode/extensions/vscode-utils.nix:106:12:

          105|     identifier = {
          106|       id = ext.vscodeExtUniqueId;
             |            ^
          107|       uuid = "";
(use '--show-trace' to show detailed location information)

I am trying to use base16 colorscheme using my own custom extension. Here is what the code looks like:

theme.nix:

<rest is just colors>

"package.json" = __toJSON {
      name = "theme";
      displayName = "Xi's generated theme";
      version = "0.0.0";
      publisher = "Xi";
      engines.vscode = "^1.22.0";
      contributes.themes = [
        {
          label = "Xi's generated theme";
          uiTheme = "vs-dark";
          path = "./theme/generated.json";
        }
      ];
      capabilities = {
        untrustedWorkspaces.supported = true;
        virtualWorkspaces = true;
      };
    };
  };
in
  with builtins;
    linkFarm "xi.theme" (attrValues (mapAttrs (name: value: {
        name = "share/vscode/extensions/xi.theme/${name}";
        path = toFile (baseNameOf name) value;
      })
      theme))

And then just call it like this:

programs.vscode.extensions =
        with extensions.open-vsx;
        with extensions.vscode-marketplace;
        with pkgs.vscode-extensions; [
          (pkgs.callPackage ./theme.nix {} osConfig.modules.themes.colors)

From what you wrote, I expected to see the word “unique” somewhere in the PR you linked to, but I don’t.

I was able to solve it with custom derivation following vscode-utils:

src = linkFarm "${publisher}.${pname}" (builtins.attrValues (builtins.mapAttrs (name: value: {
      name = "${name}";
      path = builtins.toFile (baseNameOf name) value;
    })
    theme));
in
  pkgs.stdenv.mkDerivation {
    name = "${publisher}-${pname}-${version}";
    inherit version;

    passthru = {
      inherit vscodeExtPublisher vscodeExtName vscodeExtUniqueId;
    };

    inherit src;

    configurePhase = ''
      runHook preConfigure
      runHook postConfigure
    '';

    buildPhase = ''
      runHook preBuild
      runHook postBuild
    '';

    dontPatchELF = true;
    dontStrip = true;
    installPrefix = "share/vscode/extensions/${vscodeExtUniqueId}";
    nativeBuildInputs = [pkgs.unzip];

    installPhase = ''

      runHook preInstall

      mkdir -p "$out/$installPrefix"
      find . -mindepth 1 -maxdepth 1 | xargs -d'\n' mv -t "$out/$installPrefix/"

      runHook postInstall
    '';
  }