mas: add updateScript (#509753)

This commit is contained in:
Eman Resu
2026-07-16 17:30:35 +00:00
committed by GitHub
2 changed files with 21 additions and 0 deletions

View File

@@ -9,6 +9,7 @@
versionCheckHook,
zsh,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "mas";
version = "7.0.0";
@@ -60,6 +61,8 @@ stdenvNoCC.mkDerivation (finalAttrs: {
nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;
passthru.updateScript = ./update.sh;
meta = {
description = "Mac App Store command line interface";
homepage = "https://github.com/mas-cli/mas";
@@ -67,6 +70,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
mainProgram = "mas";
maintainers = with lib.maintainers; [
zachcoyle
tiferrei
];
platforms = [
"aarch64-darwin"

17
pkgs/by-name/ma/mas/update.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq nurl gnused
set -eu
ROOT="$(dirname "$(readlink -f "$0")")"
NIX_DRV="$ROOT/package.nix"
VERSION="$(curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} https://api.github.com/repos/mas-cli/mas/releases/latest \
| jq -r '.tag_name | ltrimstr("v")')"
URL="https://github.com/mas-cli/mas/releases/download/v${VERSION}/mas-${VERSION}-arm64.pkg"
HASH=$(nurl --hash --expr \
"(import <nixpkgs> { }).fetchurl { url = \"$URL\"; }")
sed -i "s/version = \".*\"/version = \"$VERSION\"/" "$NIX_DRV"
sed -i "/arm64.pkg\";/{n; s|hash = \"sha256-.\{44\}\"|hash = \"$HASH\"|}" "$NIX_DRV"