warp-terminal: fix update.sh

can not use `import <nixpkgs>` on update machine as `<nixpkgs>` does not
exist. therefore cd to the `warp-terminal` directory and use the
relative path to nixpkgs root.

https://r.ryantm.com/log/warp-terminal/2024-03-19.log
This commit is contained in:
annalee 2024-03-23 07:57:09 +00:00
parent e1ad98971a
commit 230bb1ac5b
No known key found for this signature in database

View File

@ -3,7 +3,8 @@
#shellcheck shell=bash #shellcheck shell=bash
set -eu -o pipefail set -eu -o pipefail
dirname="$(dirname "$0")" cd "$(dirname "$0")"
nixpkgs=../../../../.
err() { err() {
echo "$*" >&2 echo "$*" >&2
@ -11,11 +12,11 @@ err() {
} }
json_get() { json_get() {
jq -r "$1" < "$dirname/versions.json" jq -r "$1" < "./versions.json"
} }
json_set() { json_set() {
jq --arg x "$2" "$1 = \$x" < "$dirname/versions.json" | sponge "$dirname/versions.json" jq --arg x "$2" "$1 = \$x" < "./versions.json" | sponge "./versions.json"
} }
resolve_url() { resolve_url() {
@ -53,10 +54,10 @@ get_version() {
sri_get() { sri_get() {
local ouput sri local ouput sri
output=$(nix-build --expr \ output=$(nix-build --expr \
'with import <nixpkgs>{}; "with import $nixpkgs {};
fetchurl { fetchurl {
url = "'"$1"'"; url = \"$1\";
}' 2>&1 || true) }" 2>&1 || true)
sri=$(echo "$output" | awk '/^\s+got:\s+/{ print $2 }') sri=$(echo "$output" | awk '/^\s+got:\s+/{ print $2 }')
[[ -z "$sri" ]] && err "$output" [[ -z "$sri" ]] && err "$output"
echo "$sri" echo "$sri"