nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 22.05 31 lines 1.2 kB view raw
1#!/usr/bin/env nix-shell 2#! nix-shell -i oil -p jq sd nix-prefetch-github ripgrep 3 4# TODO set to `verbose` or `extdebug` once implemented in oil 5set -x 6 7const directory = $(dirname $0 | xargs realpath) 8const owner = "elixir-lsp" 9const repo = "elixir-ls" 10const latest_rev = $(curl -q https://api.github.com/repos/${owner}/${repo}/releases/latest | \ 11 jq -r '.tag_name') 12const latest_version = $(echo $latest_rev | sd 'v' '') 13const current_version = $(jq -r '.version' $directory/pin.json) 14if ("$latest_version" === "$current_version") { 15 echo "elixir-ls is already up-to-date" 16 return 0 17} else { 18 const tarball_meta = $(nix-prefetch-github $owner $repo --rev "$latest_rev") 19 const tarball_hash = "sha256-$(echo $tarball_meta | jq -r '.sha256')" 20 const sha256s = $(rg '"sha256-.+"' $directory/default.nix | sd '.+"(.+)";' '$1' ) 21 22 jq ".version = \"$latest_version\" | \ 23 .\"sha256\" = \"$tarball_hash\" | \ 24 .\"depsSha256\" = \"\"" $directory/pin.json | sponge $directory/pin.json 25 26 const new_mix_hash = $(nix-build -A elixir_ls.mixFodDeps 2>&1 | \ 27 tail -n 1 | \ 28 sd '\s+got:\s+' '') 29 30 jq ".depsSha256 = \"$new_mix_hash\"" $directory/pin.json | sponge $directory/pin.json 31}