From 51785d8f0c33ebdd768dcabb7afe4d4a722c6e76 Mon Sep 17 00:00:00 2001 From: David Morgan Date: Thu, 11 Sep 2025 07:46:28 +0100 Subject: [PATCH] orbstack: init at 2.0.3-19876 Co-authored-by: Noa Virellia Co-authored-by: Sizhe Zhao --- pkgs/by-name/or/orbstack/package.nix | 79 ++++++++++++++++++++++++++++ pkgs/by-name/or/orbstack/update.sh | 24 +++++++++ 2 files changed, 103 insertions(+) create mode 100644 pkgs/by-name/or/orbstack/package.nix create mode 100755 pkgs/by-name/or/orbstack/update.sh diff --git a/pkgs/by-name/or/orbstack/package.nix b/pkgs/by-name/or/orbstack/package.nix new file mode 100644 index 000000000000..64e916d49c3f --- /dev/null +++ b/pkgs/by-name/or/orbstack/package.nix @@ -0,0 +1,79 @@ +{ + lib, + stdenvNoCC, + fetchurl, + _7zz, +}: +let + inherit (stdenvNoCC.hostPlatform) system; + version = "2.0.3-19876"; + sourceData = { + aarch64-darwin = { + arch = "arm64"; + hash = "sha256-3Ppc0zWEgR/nTS7R9uAkUYYgYu5q2TWmfd3evT+Z8g4="; + }; + x86_64-darwin = { + arch = "amd64"; + hash = "sha256-+JpyynFKmDjHLetvvEpQ0qw4crAVmx0ucWm+bvtZ2Fg="; + }; + }; + sources = lib.mapAttrs ( + system: + { arch, hash }: + fetchurl { + url = "https://cdn-updates.orbstack.dev/${arch}/OrbStack_v${ + lib.replaceString "-" "_" version + }_${arch}.dmg"; + inherit hash; + } + ) sourceData; +in +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "orbstack"; + inherit version; + + src = finalAttrs.passthru.sources.${system} or (throw "unsupported system ${system}"); + + # -snld prevents "ERROR: Dangerous symbolic link path was ignored" + # -xr'!*:com.apple.*' prevents macOS extended attributes (e.g. macl or + # quarantine) being turned into real files when extracting an APFS .dmg + # (e.g. Info.plist:com.apple.macl or Info.plist:com.apple.quarantine). + # These bogus files corrupt the .app bundle and prevent it from launching. + unpackCmd = "7zz x -snld -xr'!*:com.apple.*' $curSrc"; + + nativeBuildInputs = [ _7zz ]; + + sourceRoot = "."; + + installPhase = '' + runHook preInstall + + mkdir -p "$out/Applications" + cp -R OrbStack.app "$out/Applications" + + mkdir -p "$out/bin" + for binary in "$out"/Applications/OrbStack.app/Contents/MacOS/{bin,xbin}/*; do + ln -s "$binary" "$out/bin/$(basename "$binary")" + done + + runHook postInstall + ''; + + passthru = { + inherit sources; + updateScript = ./update.sh; + }; + + meta = { + changelog = "https://docs.orbstack.dev/release-notes#${ + builtins.replaceStrings [ "." ] [ "-" ] version + }"; + description = "Fast, light, and easy way to run Docker containers and Linux machines"; + homepage = "https://orbstack.dev/"; + license = lib.licenses.unfree; + mainProgram = "orb"; + maintainers = with lib.maintainers; [ deejayem ]; + platforms = lib.platforms.darwin; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + }; +}) diff --git a/pkgs/by-name/or/orbstack/update.sh b/pkgs/by-name/or/orbstack/update.sh new file mode 100755 index 000000000000..39c1c2ffe787 --- /dev/null +++ b/pkgs/by-name/or/orbstack/update.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p coreutils curl gawk gnugrep gnused common-updater-scripts +#shellcheck shell=bash + +set -eu -o pipefail + +update_arch() { + local arch="$1" + local system="$2" + + local source_url + source_url="$(curl -L -I "https://orbstack.dev/download/stable/latest/$arch" | grep -i "location:" | awk '{print $2}' | tr -d '\r')" + + local version + version="$(echo "$source_url" | grep -o '\([0-9]\+\.\)\{2\}[0-9]\+_[0-9]\+' | sed 's/_/-/')" + + local hash + hash=$(nix --extra-experimental-features nix-command hash convert --to sri --hash-algo sha256 "$(nix-prefetch-url --type sha256 "$source_url")") + + update-source-version orbstack "$version" "$hash" --system="$system" --source-key="sources.$system" --ignore-same-version +} + +update_arch "arm64" "aarch64-darwin" +update_arch "amd64" "x86_64-darwin"