From 906b72919107560424bc79fae7cb21abd8c4f50f Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Sat, 13 Jun 2020 08:49:24 +0200 Subject: [PATCH 1/2] vscode, vscodium: add update.sh script --- pkgs/applications/editors/vscode/update.sh | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 pkgs/applications/editors/vscode/update.sh diff --git a/pkgs/applications/editors/vscode/update.sh b/pkgs/applications/editors/vscode/update.sh new file mode 100755 index 00000000000..7453cc9c89c --- /dev/null +++ b/pkgs/applications/editors/vscode/update.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +command -v grep >/dev/null 2>&1 || { echo >&2 "[grep] is required, but not installed. Aborting."; exit 1; } +command -v awk >/dev/null 2>&1 || { echo >&2 "[awk] is required, but not installed. Aborting."; exit 1; } +command -v sed >/dev/null 2>&1 || { echo >&2 "[sed] is required, but not installed. Aborting."; exit 1; } +command -v curl >/dev/null 2>&1 || { echo >&2 "[curl] is required, but not installed. Aborting."; exit 1; } +command -v nix-prefetch-url >/dev/null 2>&1 || { echo >&2 "[nix-prefetch-url] is required, but not installed. Aborting."; exit 1; } + +ROOT="$(dirname "$(readlink -f "$0")")" +if [ ! -f "$ROOT/vscode.nix" ]; then + echo "ERROR: cannot find vscode.nix in $ROOT" + exit 1 +fi +if [ ! -f "$ROOT/vscodium.nix" ]; then + echo "ERROR: cannot find vscodium.nix in $ROOT" + exit 1 +fi + +# VSCode + +VSCODE_VER=$(curl -s -L "https://code.visualstudio.com/Download" | grep "is now available" | awk -F'' '{print $1}' | awk -F'>' '{print $NF}') +VSCODE_VER=$(curl -s -L "https://code.visualstudio.com/updates/v${VSCODE_VER/./_}" | grep "Downloads:" | awk -F'code.visualstudio.com/' '{print $2}' | awk -F'/' '{print $1}') +sed -i "s/version = \".*\"/version = \"${VSCODE_VER}\"/" "$ROOT/vscode.nix" + +VSCODE_LINUX_URL="https://vscode-update.azurewebsites.net/${VSCODE_VER}/linux-x64/stable" +VSCODE_LINUX_SHA256=$(nix-prefetch-url ${VSCODE_LINUX_URL}) +sed -i "s/x86_64-linux = \".\{52\}\"/x86_64-linux = \"${VSCODE_LINUX_SHA256}\"/" "$ROOT/vscode.nix" + +VSCODE_DARWIN_URL="https://vscode-update.azurewebsites.net/${VSCODE_VER}/darwin/stable" +VSCODE_DARWIN_SHA256=$(nix-prefetch-url ${VSCODE_DARWIN_URL}) +sed -i "s/x86_64-darwin = \".\{52\}\"/x86_64-darwin = \"${VSCODE_DARWIN_SHA256}\"/" "$ROOT/vscode.nix" + +# VSCodium + +VSCODIUM_VER=$(curl -Ls -w %{url_effective} -o /dev/null https://github.com/VSCodium/vscodium/releases/latest | awk -F'/' '{print $NF}') +sed -i "s/version = \".*\"/version = \"${VSCODIUM_VER}\"/" "$ROOT/vscodium.nix" + +VSCODIUM_LINUX_URL="https://github.com/VSCodium/vscodium/releases/download/${VSCODIUM_VER}/VSCodium-linux-x64-${VSCODIUM_VER}.tar.gz" +VSCODIUM_LINUX_SHA256=$(nix-prefetch-url ${VSCODIUM_LINUX_URL}) +sed -i "s/x86_64-linux = \".\{52\}\"/x86_64-linux = \"${VSCODIUM_LINUX_SHA256}\"/" "$ROOT/vscodium.nix" + +VSCODIUM_DARWIN_URL="https://github.com/VSCodium/vscodium/releases/download/${VSCODIUM_VER}/VSCodium-darwin-${VSCODIUM_VER}.zip" +VSCODIUM_DARWIN_SHA256=$(nix-prefetch-url ${VSCODIUM_DARWIN_URL}) +sed -i "s/x86_64-darwin = \".\{52\}\"/x86_64-darwin = \"${VSCODIUM_DARWIN_SHA256}\"/" "$ROOT/vscodium.nix" \ No newline at end of file From 05e16d2886e90d799b5076099142b68def21cf6e Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Sat, 13 Jun 2020 08:56:51 +0200 Subject: [PATCH 2/2] vscode, vscodium: use nix-shell to install dependencies --- pkgs/applications/editors/vscode/update.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pkgs/applications/editors/vscode/update.sh b/pkgs/applications/editors/vscode/update.sh index 7453cc9c89c..d573fdf04aa 100755 --- a/pkgs/applications/editors/vscode/update.sh +++ b/pkgs/applications/editors/vscode/update.sh @@ -1,10 +1,5 @@ -#!/usr/bin/env bash - -command -v grep >/dev/null 2>&1 || { echo >&2 "[grep] is required, but not installed. Aborting."; exit 1; } -command -v awk >/dev/null 2>&1 || { echo >&2 "[awk] is required, but not installed. Aborting."; exit 1; } -command -v sed >/dev/null 2>&1 || { echo >&2 "[sed] is required, but not installed. Aborting."; exit 1; } -command -v curl >/dev/null 2>&1 || { echo >&2 "[curl] is required, but not installed. Aborting."; exit 1; } -command -v nix-prefetch-url >/dev/null 2>&1 || { echo >&2 "[nix-prefetch-url] is required, but not installed. Aborting."; exit 1; } +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl gnugrep gnused gawk ROOT="$(dirname "$(readlink -f "$0")")" if [ ! -f "$ROOT/vscode.nix" ]; then