Commit 762fcb12 authored by emaryn's avatar emaryn
Browse files

vscode-extensions.ms-python.python: use vscode-extensions-update-script

parent 4f1a07ba
Loading
Loading
Loading
Loading
+2 −36
Original line number Diff line number Diff line
@@ -8,13 +8,7 @@
  # Defaults to `false` as we expect it to be project specific most of the time.
  pythonUseFixed ? false,
  # For updateScript
  writeScript,
  bash,
  curl,
  coreutils,
  gnused,
  jq,
  nix,
  vscode-extensions-update-script,
}:

vscode-utils.buildVscodeMarketplaceExtension rec {
@@ -51,35 +45,7 @@ vscode-utils.buildVscodeMarketplaceExtension rec {
        --replace-fail "\"default\":\"python\"" "\"default\":\"${python3.interpreter}\""
    '';

  passthru.updateScript = writeScript "update" ''
    #! ${bash}/bin/bash

    set -eu -o pipefail

    export PATH=${
      lib.makeBinPath [
        curl
        coreutils
        gnused
        jq
        nix
      ]
    }

    api=$(curl -s 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery' \
      -H 'accept: application/json;api-version=3.0-preview.1' \
      -H 'content-type: application/json' \
      --data-raw '{"filters":[{"criteria":[{"filterType":7,"value":"${mktplcRef.publisher}.${mktplcRef.name}"}]}],"flags":16}')
    # Find the latest version compatible with stable vscode version
    version=$(echo $api | jq -r '.results[0].extensions[0].versions | map(select(has("properties"))) | map(select(.properties | map(select(.key == "Microsoft.VisualStudio.Code.Engine")) | .[0].value | test("\\^[0-9.]+$"))) | .[0].version')

    if [[ $version != ${mktplcRef.version} ]]; then
      tmp=$(mktemp)
      curl -sLo $tmp $(echo ${(import ../mktplcExtRefToFetchArgs.nix mktplcRef).url} | sed "s|${mktplcRef.version}|$version|")
      hash=$(nix hash file --type sha256 --base32 --sri $tmp)
      sed -i -e "s|${mktplcRef.hash}|$hash|" -e "s|${mktplcRef.version}|$version|" pkgs/applications/editors/vscode/extensions/ms-python.python/default.nix
    fi
  '';
  passthru.updateScript = vscode-extensions-update-script { };

  meta = {
    description = "Visual Studio Code extension with rich support for the Python language";