Loading pkgs/applications/editors/vscode/extensions/ms-dotnettools.csharp/default.nix +38 −21 Original line number Diff line number Diff line Loading @@ -10,30 +10,33 @@ coreutils, }: let inherit (stdenv.hostPlatform) system; inherit (vscode-utils) buildVscodeMarketplaceExtension; lockfile = lib.importJSON ./lockfile.json; extInfo = (arch: { inherit arch; inherit (lockfile.${arch}) hash binaries; }) ( extInfo = ( { x86_64-linux = "linux-x64"; aarch64-linux = "linux-arm64"; x86_64-darwin = "darwin-x64"; aarch64-darwin = "darwin-arm64"; x86_64-linux = { arch = "linux-x64"; hash = "sha256-YmlXnmLp0ZtFvHXOsI0sLySLprU+ntduywvvlZ2Riw0="; }; aarch64-linux = { arch = "linux-arm64"; hash = "sha256-QBon9zOXykngvJHydJQPdgjvLxy65DbWS+IUAzo638o="; }; x86_64-darwin = { arch = "darwin-x64"; hash = "sha256-fOfCm+XiD5NVexMlBeBfSxtTr9mTnn2HKFsJjuGBCJ0="; }; aarch64-darwin = { arch = "darwin-arm64"; hash = "sha256-e1cxz8A2IlO6fnN41PKXqPxthTuAOmAWy6/kRck6hsM="; }; } .${system} or (throw "Unsupported system: ${system}") .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}") ); in buildVscodeMarketplaceExtension { vscode-utils.buildVscodeMarketplaceExtension { mktplcRef = { name = "csharp"; publisher = "ms-dotnettools"; inherit (lockfile) version; version = "2.72.27"; inherit (extInfo) hash arch; }; Loading @@ -52,8 +55,22 @@ buildVscodeMarketplaceExtension { postPatch = '' substituteInPlace dist/extension.js \ --replace-fail 'uname -m' '${lib.getExe' coreutils "uname"} -m' ''; preFixup = '' ( shopt -s globstar shopt -s dotglob for file in "$out"/**/*; do if [[ ! -f "$file" || "$file" == *.so || "$file" == *.dylib ]] || (! isELF "$file" && ! isMachO "$file"); then continue fi chmod +x ${lib.escapeShellArgs extInfo.binaries} echo Making "$file" executable... chmod +x "$file" done ) ''; passthru.updateScript = ./update.sh; Loading pkgs/applications/editors/vscode/extensions/ms-dotnettools.csharp/lockfile.jsondeleted 100644 → 0 +0 −46 Original line number Diff line number Diff line { "version": "2.69.25", "linux-x64": { "hash": "sha256-RG3iuQXEePJvn9kh58tkXJeakdh6w8W1D4A6hn7NhQs=", "binaries": [ ".debugger/createdump", ".debugger/vsdbg", ".debugger/vsdbg-ui", ".razor/rzls", ".roslyn/Microsoft.CodeAnalysis.LanguageServer" ] }, "linux-arm64": { "hash": "sha256-sMUUS90uXEnIc8QyQ7Vk8/bhaUcqgwWIPObl8/qkkYI=", "binaries": [ ".debugger/createdump", ".debugger/vsdbg", ".debugger/vsdbg-ui", ".razor/rzls", ".roslyn/Microsoft.CodeAnalysis.LanguageServer" ] }, "darwin-x64": { "hash": "sha256-7jdVpzEx1zqvtSbr7Z6g5YnlNJyCK33g2REbx27X5Ls=", "binaries": [ ".debugger/x86_64/createdump", ".debugger/x86_64/vsdbg", ".debugger/x86_64/vsdbg-ui", ".razor/rzls", ".roslyn/Microsoft.CodeAnalysis.LanguageServer" ] }, "darwin-arm64": { "hash": "sha256-Oz6gGQbZwcAoy8m1mLQxOQypjoo6LQc/j1OcRX94YII=", "binaries": [ ".debugger/arm64/createdump", ".debugger/arm64/vsdbg", ".debugger/arm64/vsdbg-ui", ".debugger/x86_64/createdump", ".debugger/x86_64/vsdbg", ".debugger/x86_64/vsdbg-ui", ".razor/rzls", ".roslyn/Microsoft.CodeAnalysis.LanguageServer" ] } } pkgs/applications/editors/vscode/extensions/ms-dotnettools.csharp/update.sh +10 −122 Original line number Diff line number Diff line #!/usr/bin/env nix-shell #!nix-shell -I nixpkgs=./. -i bash -p curl coreutils jq nix unzip #!nix-shell -I nixpkgs=./. -i bash -p curl jq nix common-updater-scripts # shellcheck shell=bash set -euo pipefail shopt -s globstar shopt -s dotglob export LC_ALL=C PUBLISHER=ms-dotnettools EXTENSION=csharp LOCKFILE=pkgs/applications/editors/vscode/extensions/$PUBLISHER.$EXTENSION/lockfile.json response=$(curl -s 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery' \ -H 'accept: application/json;api-version=3.0-preview.1' \ Loading @@ -24,58 +21,12 @@ latest_version=$(jq --raw-output ' | map(select(.properties | map(select(.key == "Microsoft.VisualStudio.Code.PreRelease")) | .[0].value != "true")) | .[0].version' <<<"$response") current_version=$(jq '.version' --raw-output <"$LOCKFILE") if [[ "$latest_version" == "$current_version" ]]; then echo "Package is up to date." >&2 exit 1 fi # Return success if the specified file is an ELF object. isELF() { local fn="$1" local fd local magic exec {fd}<"$fn" read -r -n 4 -u "$fd" magic exec {fd}<&- if [ "$magic" = $'\177ELF' ]; then return 0; else return 1; fi } # Return success if the specified file is a Mach-O object. isMachO() { local fn="$1" local fd local magic exec {fd}<"$fn" read -r -n 4 -u "$fd" magic exec {fd}<&- # nix uses 'declare -F' in get-env.sh to retrieve the loaded functions. # If we use the $'string' syntax instead of 'echo -ne' then 'declare' will print the raw characters and break nix. # See https://github.com/NixOS/nixpkgs/pull/138334 and https://github.com/NixOS/nix/issues/5262. # https://opensource.apple.com/source/lldb/lldb-310.2.36/examples/python/mach_o.py.auto.html if [[ "$magic" = $(echo -ne "\xfe\xed\xfa\xcf") || "$magic" = $(echo -ne "\xcf\xfa\xed\xfe") ]]; then # MH_MAGIC_64 || MH_CIGAM_64 return 0 elif [[ "$magic" = $(echo -ne "\xfe\xed\xfa\xce") || "$magic" = $(echo -ne "\xce\xfa\xed\xfe") ]]; then # MH_MAGIC || MH_CIGAM return 0 elif [[ "$magic" = $(echo -ne "\xca\xfe\xba\xbe") || "$magic" = $(echo -ne "\xbe\xba\xfe\xca") ]]; then # FAT_MAGIC || FAT_CIGAM return 0 else return 1 fi } getDownloadUrl() { nix-instantiate \ --eval \ --strict \ --json \ pkgs/applications/editors/vscode/extensions/mktplcExtRefToFetchArgs.nix \ 'pkgs/applications/editors/vscode/extensions/mktplcExtRefToFetchArgs.nix' \ --attr url \ --argstr publisher $PUBLISHER \ --argstr name $EXTENSION \ Loading @@ -83,76 +34,13 @@ getDownloadUrl() { --argstr arch "$1" | jq . --raw-output } TEMP=$(mktemp --directory --tmpdir) OUTPUT="$TEMP/lockfile.json" trap 'rm -r "$TEMP"' EXIT HASH= BINARIES=() fetchMarketplace() { arch="$1" echo " Downloading VSIX..." if ! curl -sLo "$TEMP/$arch".zip "$(getDownloadUrl "$arch")"; then echo " Failed to download extension for arch $arch" >&2 exit 1 fi HASH=$(nix hash file --type sha256 --sri "$TEMP/$arch".zip) BINARIES=() echo " Extracting VSIX..." mkdir "$TEMP/$arch" if ! unzip "$TEMP/$arch".zip -d "$TEMP/$arch" >/dev/null; then echo " Failed to unzip extension for arch $arch" >&2 file "$TEMP/$arch".zip >&2 exit 1 fi echo " Listing binaries..." for file in "$TEMP/$arch"/**/*; do if [[ ! -f "$file" || "$file" == *.so || "$file" == *.dylib ]] || (! isELF "$file" && ! isMachO "$file"); then continue fi echo " FOUND: ${file#"$TEMP/$arch/extension/"}" BINARIES+=("${file#"$TEMP/$arch/extension/"}") done rm -r "${TEMP:?}/$arch" update_hash() { local hash hash=$(nix hash convert --hash-algo sha256 "$(nix-prefetch-url --type sha256 "$(getDownloadUrl "$2")")") update-source-version vscode-extensions.$PUBLISHER.$EXTENSION "$latest_version" "$hash" --system="$1" --ignore-same-version } cat >"$OUTPUT" <<EOF { "version": "$latest_version", EOF firstArch=true for arch in linux-x64 linux-arm64 darwin-x64 darwin-arm64; do if [ "$firstArch" = false ]; then echo -e ',' >>"$OUTPUT" fi firstArch=false echo "Getting data for $arch..." fetchMarketplace "$arch" cat >>"$OUTPUT" <<EOF "$arch": { "hash": "$HASH", "binaries": [ EOF firstBin=true for binary in "${BINARIES[@]}"; do if [ "$firstBin" = false ]; then echo -e ',' >>"$OUTPUT" fi firstBin=false echo -n " \"$binary\"" >>"$OUTPUT" done echo -ne '\n ]\n }' >>"$OUTPUT" done echo -e '\n}' >>"$OUTPUT" mv "$OUTPUT" "$LOCKFILE" update_hash x86_64-linux linux-x64 update_hash aarch64-linux linux-arm64 update_hash x86_64-darwin darwin-x64 update_hash aarch64-darwin darwin-arm64 Loading
pkgs/applications/editors/vscode/extensions/ms-dotnettools.csharp/default.nix +38 −21 Original line number Diff line number Diff line Loading @@ -10,30 +10,33 @@ coreutils, }: let inherit (stdenv.hostPlatform) system; inherit (vscode-utils) buildVscodeMarketplaceExtension; lockfile = lib.importJSON ./lockfile.json; extInfo = (arch: { inherit arch; inherit (lockfile.${arch}) hash binaries; }) ( extInfo = ( { x86_64-linux = "linux-x64"; aarch64-linux = "linux-arm64"; x86_64-darwin = "darwin-x64"; aarch64-darwin = "darwin-arm64"; x86_64-linux = { arch = "linux-x64"; hash = "sha256-YmlXnmLp0ZtFvHXOsI0sLySLprU+ntduywvvlZ2Riw0="; }; aarch64-linux = { arch = "linux-arm64"; hash = "sha256-QBon9zOXykngvJHydJQPdgjvLxy65DbWS+IUAzo638o="; }; x86_64-darwin = { arch = "darwin-x64"; hash = "sha256-fOfCm+XiD5NVexMlBeBfSxtTr9mTnn2HKFsJjuGBCJ0="; }; aarch64-darwin = { arch = "darwin-arm64"; hash = "sha256-e1cxz8A2IlO6fnN41PKXqPxthTuAOmAWy6/kRck6hsM="; }; } .${system} or (throw "Unsupported system: ${system}") .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}") ); in buildVscodeMarketplaceExtension { vscode-utils.buildVscodeMarketplaceExtension { mktplcRef = { name = "csharp"; publisher = "ms-dotnettools"; inherit (lockfile) version; version = "2.72.27"; inherit (extInfo) hash arch; }; Loading @@ -52,8 +55,22 @@ buildVscodeMarketplaceExtension { postPatch = '' substituteInPlace dist/extension.js \ --replace-fail 'uname -m' '${lib.getExe' coreutils "uname"} -m' ''; preFixup = '' ( shopt -s globstar shopt -s dotglob for file in "$out"/**/*; do if [[ ! -f "$file" || "$file" == *.so || "$file" == *.dylib ]] || (! isELF "$file" && ! isMachO "$file"); then continue fi chmod +x ${lib.escapeShellArgs extInfo.binaries} echo Making "$file" executable... chmod +x "$file" done ) ''; passthru.updateScript = ./update.sh; Loading
pkgs/applications/editors/vscode/extensions/ms-dotnettools.csharp/lockfile.jsondeleted 100644 → 0 +0 −46 Original line number Diff line number Diff line { "version": "2.69.25", "linux-x64": { "hash": "sha256-RG3iuQXEePJvn9kh58tkXJeakdh6w8W1D4A6hn7NhQs=", "binaries": [ ".debugger/createdump", ".debugger/vsdbg", ".debugger/vsdbg-ui", ".razor/rzls", ".roslyn/Microsoft.CodeAnalysis.LanguageServer" ] }, "linux-arm64": { "hash": "sha256-sMUUS90uXEnIc8QyQ7Vk8/bhaUcqgwWIPObl8/qkkYI=", "binaries": [ ".debugger/createdump", ".debugger/vsdbg", ".debugger/vsdbg-ui", ".razor/rzls", ".roslyn/Microsoft.CodeAnalysis.LanguageServer" ] }, "darwin-x64": { "hash": "sha256-7jdVpzEx1zqvtSbr7Z6g5YnlNJyCK33g2REbx27X5Ls=", "binaries": [ ".debugger/x86_64/createdump", ".debugger/x86_64/vsdbg", ".debugger/x86_64/vsdbg-ui", ".razor/rzls", ".roslyn/Microsoft.CodeAnalysis.LanguageServer" ] }, "darwin-arm64": { "hash": "sha256-Oz6gGQbZwcAoy8m1mLQxOQypjoo6LQc/j1OcRX94YII=", "binaries": [ ".debugger/arm64/createdump", ".debugger/arm64/vsdbg", ".debugger/arm64/vsdbg-ui", ".debugger/x86_64/createdump", ".debugger/x86_64/vsdbg", ".debugger/x86_64/vsdbg-ui", ".razor/rzls", ".roslyn/Microsoft.CodeAnalysis.LanguageServer" ] } }
pkgs/applications/editors/vscode/extensions/ms-dotnettools.csharp/update.sh +10 −122 Original line number Diff line number Diff line #!/usr/bin/env nix-shell #!nix-shell -I nixpkgs=./. -i bash -p curl coreutils jq nix unzip #!nix-shell -I nixpkgs=./. -i bash -p curl jq nix common-updater-scripts # shellcheck shell=bash set -euo pipefail shopt -s globstar shopt -s dotglob export LC_ALL=C PUBLISHER=ms-dotnettools EXTENSION=csharp LOCKFILE=pkgs/applications/editors/vscode/extensions/$PUBLISHER.$EXTENSION/lockfile.json response=$(curl -s 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery' \ -H 'accept: application/json;api-version=3.0-preview.1' \ Loading @@ -24,58 +21,12 @@ latest_version=$(jq --raw-output ' | map(select(.properties | map(select(.key == "Microsoft.VisualStudio.Code.PreRelease")) | .[0].value != "true")) | .[0].version' <<<"$response") current_version=$(jq '.version' --raw-output <"$LOCKFILE") if [[ "$latest_version" == "$current_version" ]]; then echo "Package is up to date." >&2 exit 1 fi # Return success if the specified file is an ELF object. isELF() { local fn="$1" local fd local magic exec {fd}<"$fn" read -r -n 4 -u "$fd" magic exec {fd}<&- if [ "$magic" = $'\177ELF' ]; then return 0; else return 1; fi } # Return success if the specified file is a Mach-O object. isMachO() { local fn="$1" local fd local magic exec {fd}<"$fn" read -r -n 4 -u "$fd" magic exec {fd}<&- # nix uses 'declare -F' in get-env.sh to retrieve the loaded functions. # If we use the $'string' syntax instead of 'echo -ne' then 'declare' will print the raw characters and break nix. # See https://github.com/NixOS/nixpkgs/pull/138334 and https://github.com/NixOS/nix/issues/5262. # https://opensource.apple.com/source/lldb/lldb-310.2.36/examples/python/mach_o.py.auto.html if [[ "$magic" = $(echo -ne "\xfe\xed\xfa\xcf") || "$magic" = $(echo -ne "\xcf\xfa\xed\xfe") ]]; then # MH_MAGIC_64 || MH_CIGAM_64 return 0 elif [[ "$magic" = $(echo -ne "\xfe\xed\xfa\xce") || "$magic" = $(echo -ne "\xce\xfa\xed\xfe") ]]; then # MH_MAGIC || MH_CIGAM return 0 elif [[ "$magic" = $(echo -ne "\xca\xfe\xba\xbe") || "$magic" = $(echo -ne "\xbe\xba\xfe\xca") ]]; then # FAT_MAGIC || FAT_CIGAM return 0 else return 1 fi } getDownloadUrl() { nix-instantiate \ --eval \ --strict \ --json \ pkgs/applications/editors/vscode/extensions/mktplcExtRefToFetchArgs.nix \ 'pkgs/applications/editors/vscode/extensions/mktplcExtRefToFetchArgs.nix' \ --attr url \ --argstr publisher $PUBLISHER \ --argstr name $EXTENSION \ Loading @@ -83,76 +34,13 @@ getDownloadUrl() { --argstr arch "$1" | jq . --raw-output } TEMP=$(mktemp --directory --tmpdir) OUTPUT="$TEMP/lockfile.json" trap 'rm -r "$TEMP"' EXIT HASH= BINARIES=() fetchMarketplace() { arch="$1" echo " Downloading VSIX..." if ! curl -sLo "$TEMP/$arch".zip "$(getDownloadUrl "$arch")"; then echo " Failed to download extension for arch $arch" >&2 exit 1 fi HASH=$(nix hash file --type sha256 --sri "$TEMP/$arch".zip) BINARIES=() echo " Extracting VSIX..." mkdir "$TEMP/$arch" if ! unzip "$TEMP/$arch".zip -d "$TEMP/$arch" >/dev/null; then echo " Failed to unzip extension for arch $arch" >&2 file "$TEMP/$arch".zip >&2 exit 1 fi echo " Listing binaries..." for file in "$TEMP/$arch"/**/*; do if [[ ! -f "$file" || "$file" == *.so || "$file" == *.dylib ]] || (! isELF "$file" && ! isMachO "$file"); then continue fi echo " FOUND: ${file#"$TEMP/$arch/extension/"}" BINARIES+=("${file#"$TEMP/$arch/extension/"}") done rm -r "${TEMP:?}/$arch" update_hash() { local hash hash=$(nix hash convert --hash-algo sha256 "$(nix-prefetch-url --type sha256 "$(getDownloadUrl "$2")")") update-source-version vscode-extensions.$PUBLISHER.$EXTENSION "$latest_version" "$hash" --system="$1" --ignore-same-version } cat >"$OUTPUT" <<EOF { "version": "$latest_version", EOF firstArch=true for arch in linux-x64 linux-arm64 darwin-x64 darwin-arm64; do if [ "$firstArch" = false ]; then echo -e ',' >>"$OUTPUT" fi firstArch=false echo "Getting data for $arch..." fetchMarketplace "$arch" cat >>"$OUTPUT" <<EOF "$arch": { "hash": "$HASH", "binaries": [ EOF firstBin=true for binary in "${BINARIES[@]}"; do if [ "$firstBin" = false ]; then echo -e ',' >>"$OUTPUT" fi firstBin=false echo -n " \"$binary\"" >>"$OUTPUT" done echo -ne '\n ]\n }' >>"$OUTPUT" done echo -e '\n}' >>"$OUTPUT" mv "$OUTPUT" "$LOCKFILE" update_hash x86_64-linux linux-x64 update_hash aarch64-linux linux-arm64 update_hash x86_64-darwin darwin-x64 update_hash aarch64-darwin darwin-arm64