Unverified Commit 51785d8f authored by David Morgan's avatar David Morgan
Browse files

orbstack: init at 2.0.3-19876



Co-authored-by: default avatarNoa Virellia <cmiki@amono.me>
Co-authored-by: default avatarSizhe Zhao <prc.zhao@outlook.com>
parent e0ea8de2
Loading
Loading
Loading
Loading
+79 −0
Original line number Diff line number Diff line
{
  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 ];
  };
})
+24 −0
Original line number Diff line number Diff line
#!/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"