summary refs log tree commit diff
path: root/pkgs/misc/urbit/update-bin.sh
diff options
context:
space:
mode:
authorMatthew LeVan <matthew@coeli.network>2023-02-16 20:46:04 -0500
committerMatthew LeVan <matthew@coeli.network>2023-02-21 11:27:05 -0500
commit0e973e43c040e79f3e95bb2488fea6afd0fb5186 (patch)
tree1d2d3283c2dd3d3c72e1d1e916215c631253164e /pkgs/misc/urbit/update-bin.sh
parent1f9748835ce2b81a8ee14e5caa7c0cca062d9619 (diff)
downloadnixpkgs-0e973e43c040e79f3e95bb2488fea6afd0fb5186.tar
nixpkgs-0e973e43c040e79f3e95bb2488fea6afd0fb5186.tar.gz
nixpkgs-0e973e43c040e79f3e95bb2488fea6afd0fb5186.tar.bz2
nixpkgs-0e973e43c040e79f3e95bb2488fea6afd0fb5186.tar.lz
nixpkgs-0e973e43c040e79f3e95bb2488fea6afd0fb5186.tar.xz
nixpkgs-0e973e43c040e79f3e95bb2488fea6afd0fb5186.tar.zst
nixpkgs-0e973e43c040e79f3e95bb2488fea6afd0fb5186.zip
urbit: remove old urbit; init at 1.20
Diffstat (limited to 'pkgs/misc/urbit/update-bin.sh')
-rwxr-xr-xpkgs/misc/urbit/update-bin.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/pkgs/misc/urbit/update-bin.sh b/pkgs/misc/urbit/update-bin.sh
new file mode 100755
index 00000000000..b7ee514e10a
--- /dev/null
+++ b/pkgs/misc/urbit/update-bin.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p curl common-updater-scripts nix-prefetch
+
+set -euo pipefail
+
+ROOT="$(dirname "$(readlink -f "$0")")"
+NIX_DRV="$ROOT/default.nix"
+if [ ! -f "$NIX_DRV" ]; then
+  echo "ERROR: cannot find urbit in $ROOT"
+  exit 1
+fi
+
+fetch_arch() {
+  VER="$1"; ARCH="$2"
+  URL="https://github.com/urbit/vere/releases/download/vere-v${VER}/${ARCH}.tgz";
+  nix-prefetch "{ stdenv, fetchzip }:
+stdenv.mkDerivation rec {
+  pname = \"vere\"; version = \"${VER}\";
+  src = fetchzip { url = \"$URL\"; };
+}
+"
+}
+
+replace_sha() {
+  sed -i "s#$1 = \"sha256-.\{44\}\"#$1 = \"$2\"#" "$NIX_DRV"
+}
+
+VERE_VER=$(curl https://bootstrap.urbit.org/vere/live/last)
+
+VERE_LINUX_AARCH64_SHA256=$(fetch_arch "$VERE_VER" "linux-aarch64")
+VERE_LINUX_X64_SHA256=$(fetch_arch "$VERE_VER" "linux-x86_64")
+VERE_DARWIN_AARCH64_SHA256=$(fetch_arch "$VERE_VER" "macos-aarch64")
+VERE_DARWIN_X64_SHA256=$(fetch_arch "$VERE_VER" "macos-x86_64")
+
+sed -i "s/version = \".*\"/version = \"$VERE_VER\"/" "$NIX_DRV"
+
+replace_sha "aarch64-linux" "$VERE_LINUX_AARCH64_SHA256"
+replace_sha "x86_64-linux" "$VERE_LINUX_X64_SHA256"
+replace_sha "aarch64-darwin" "$VERE_DARWIN_AARCH64_SHA256"
+replace_sha "x86_64-darwin" "$VERE_DARWIN_X64_SHA256"