Merge pull request #305579 from kylecarbs/master

coder: add support for mainline channel

authored by Pol Dellaiera and committed by GitHub fca59efa 0c97ced7

+58 -23
+24 -8
pkgs/development/tools/coder/default.nix
··· 1 { lib 2 , fetchurl 3 , installShellFiles 4 , makeBinaryWrapper ··· 9 10 let 11 inherit (stdenvNoCC.hostPlatform) system; 12 in 13 stdenvNoCC.mkDerivation (finalAttrs: { 14 pname = "coder"; 15 - version = "2.9.1"; 16 - 17 src = fetchurl { 18 - hash = { 19 - x86_64-linux = "sha256-r4+u/s/dOn2GhyhEROu8i03QY3VA/bIyO/Yj7KSqicY="; 20 - x86_64-darwin = "sha256-uShCmMvb5OcinqP0CmrlP9QAJkjfG3g1QuHE4JRDOjE="; 21 - aarch64-linux = "sha256-tvpzfJ95YYfCY5V4iayjAmY5PDw+1uHUhY5F3pv/2Uk="; 22 - aarch64-darwin = "sha256-sP9HnB2DzAU9IvL3+QPmIFLvRkGkoxSoa68uXGQrNkw="; 23 - }.${system}; 24 25 url = 26 let
··· 1 { lib 2 + , channel ? "stable" 3 , fetchurl 4 , installShellFiles 5 , makeBinaryWrapper ··· 10 11 let 12 inherit (stdenvNoCC.hostPlatform) system; 13 + 14 + channels = { 15 + stable = { 16 + version = "2.9.3"; 17 + hash = { 18 + x86_64-linux = "sha256-6VS21x2egWBV6eJqRCBGG7mEGPIDFtY9GN6Ry4ilC70="; 19 + x86_64-darwin = "sha256-UBUGjA+jUkT6p9714l8IvDDI/qhWNctVFOvcA2S5kQU="; 20 + aarch64-linux = "sha256-2QAahqcM2gi3lT+18q2Nm9GNqVsqzX3RajBsTn+KB1c="; 21 + aarch64-darwin = "sha256-uEH7Y7c9BcU/Q/jwx/inFMvUrgm2dUruID+FJL+rA6Y="; 22 + }; 23 + }; 24 + mainline = { 25 + version = "2.10.1"; 26 + hash = { 27 + x86_64-linux = "sha256-jNPL30e5xvyajlIqivtEpSb3cRhfgFhLFlC+CaLY2IM="; 28 + x86_64-darwin = "sha256-U1eQaYwnm/mdQoZ8YxK/+s3HboVfMIAtdI7aQnCiDM8="; 29 + aarch64-linux = "sha256-YtSyKZYG8vdubZUfo2FjEoVwSF82TXzeLJjPpHqgFDk="; 30 + aarch64-darwin = "sha256-aQSiXK7voP5/mPFIscfTnSc4Ae5/f+WW8MR6ZtuC/eY="; 31 + }; 32 + }; 33 + }; 34 in 35 stdenvNoCC.mkDerivation (finalAttrs: { 36 pname = "coder"; 37 + version = channels.${channel}.version; 38 src = fetchurl { 39 + hash = (channels.${channel}.hash).${system}; 40 41 url = 42 let
+34 -15
pkgs/development/tools/coder/update.sh
··· 5 6 cd "$(dirname "${BASH_SOURCE[0]}")" 7 8 - LATEST_TAG=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} --silent https://api.github.com/repos/coder/coder/releases/latest | jq -r '.tag_name') 9 - LATEST_VERSION=$(echo ${LATEST_TAG} | sed 's/^v//') 10 11 - # change version number 12 - sed -e "s/version =.*;/version = \"$LATEST_VERSION\";/g" \ 13 - -i ./default.nix 14 15 # Define the platforms 16 declare -A ARCHS=(["x86_64-linux"]="linux_amd64.tar.gz" ··· 18 ["x86_64-darwin"]="darwin_amd64.zip" 19 ["aarch64-darwin"]="darwin_arm64.zip") 20 21 - # Update hashes for each architecture 22 - for ARCH in "${!ARCHS[@]}"; do 23 - URL="https://github.com/coder/coder/releases/download/v${LATEST_VERSION}/coder_${LATEST_VERSION}_${ARCHS[$ARCH]}" 24 - echo "Fetching hash for $ARCH..." 25 26 - # Fetch the new hash using nix-prefetch-url 27 - NEW_HASH=$(nix-prefetch-url --type sha256 $URL) 28 - SRI_HASH=$(nix hash to-sri --type sha256 $NEW_HASH) 29 30 - # Update the Nix file with the new hash 31 - sed -i "s|${ARCH} = \"sha256-.*\";|${ARCH} = \"${SRI_HASH}\";|" ./default.nix 32 - done
··· 5 6 cd "$(dirname "${BASH_SOURCE[0]}")" 7 8 + # Fetch the latest stable version 9 + LATEST_STABLE_TAG=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} --silent https://api.github.com/repos/coder/coder/releases/latest | jq -r '.tag_name') 10 + LATEST_STABLE_VERSION=$(echo ${LATEST_STABLE_TAG} | sed 's/^v//') 11 12 + # Fetch the latest mainline version 13 + LATEST_MAINLINE_TAG=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} --silent https://api.github.com/repos/coder/coder/releases | jq -r '.[0].tag_name') 14 + LATEST_MAINLINE_VERSION=$(echo ${LATEST_MAINLINE_TAG} | sed 's/^v//') 15 16 # Define the platforms 17 declare -A ARCHS=(["x86_64-linux"]="linux_amd64.tar.gz" ··· 19 ["x86_64-darwin"]="darwin_amd64.zip" 20 ["aarch64-darwin"]="darwin_arm64.zip") 21 22 + update_version_and_hashes() { 23 + local version=$1 24 + local channel=$2 25 + 26 + # Update version number, using '#' as delimiter 27 + sed -i "/${channel} = {/,/};/{ 28 + s#^\(\s*\)version = .*#\1version = \"$version\";# 29 + }" ./default.nix 30 + 31 + # Update hashes for each architecture 32 + for ARCH in "${!ARCHS[@]}"; do 33 + local URL="https://github.com/coder/coder/releases/download/v${version}/coder_${version}_${ARCHS[$ARCH]}" 34 + echo "Fetching hash for $channel/$ARCH..." 35 + 36 + # Fetch the new hash using nix-prefetch-url 37 + local NEW_HASH=$(nix-prefetch-url --type sha256 $URL) 38 + local SRI_HASH=$(nix hash to-sri --type sha256 $NEW_HASH) 39 40 + # Update the Nix file with the new hash, using '#' as delimiter and preserving indentation 41 + sed -i "/${channel} = {/,/};/{ 42 + s#^\(\s*\)${ARCH} = .*#\1${ARCH} = \"${SRI_HASH}\";# 43 + }" ./default.nix 44 + done 45 + } 46 47 + # Update stable channel 48 + update_version_and_hashes $LATEST_STABLE_VERSION "stable" 49 + 50 + # Update mainline channel 51 + update_version_and_hashes $LATEST_MAINLINE_VERSION "mainline"