feat: add aarch64-darwin (macOS) support (#80)
This commit is contained in:
48
.github/update.sh
vendored
48
.github/update.sh
vendored
@@ -51,9 +51,15 @@ beta_tag=$(get_beta_tag_short_meta)
|
||||
|
||||
get_twilight_release_artifact_meta_from_zen_repo() {
|
||||
arch=$1
|
||||
os=$2
|
||||
|
||||
echo "$twilight_tag" | tr -d '\000-\031' | jq -r --arg arch "$arch" \
|
||||
'.assets[] | select(.name | contains("zen.linux") and contains($arch)) | "\(.id) \(.name)"'
|
||||
if [ "$os" = "darwin" ]; then
|
||||
echo "$twilight_tag" | tr -d '\000-\031' | jq -r \
|
||||
'.assets[] | select(.name | contains("zen.macos-universal.dmg")) | "\(.id) \(.name)"'
|
||||
else
|
||||
echo "$twilight_tag" | tr -d '\000-\031' | jq -r --arg arch "$arch" \
|
||||
'.assets[] | select(.name | contains("zen.linux") and contains($arch)) | "\(.id) \(.name)"'
|
||||
fi
|
||||
}
|
||||
|
||||
download_artifact_from_zen_repo() {
|
||||
@@ -138,8 +144,10 @@ update_version() {
|
||||
version_name=$1
|
||||
# "x86_64" or "aarch64"
|
||||
arch=$2
|
||||
# "linux" or "darwin"
|
||||
os=$3
|
||||
|
||||
meta=$(jq ".[\"$version_name\"][\"$arch-linux\"]" <sources.json)
|
||||
meta=$(jq ".[\"$version_name\"][\"$arch-$os\"]" <sources.json)
|
||||
|
||||
local_sha1=$(echo "$meta" | jq -r '.sha1')
|
||||
remote_sha1=$(resolve_version_remote_sha1 "$version_name")
|
||||
@@ -176,9 +184,17 @@ update_version() {
|
||||
target_release_name="twilight"
|
||||
fi
|
||||
|
||||
download_url="https://github.com/zen-browser/desktop/releases/download/$target_release_name/zen.linux-$arch.tar.xz"
|
||||
if [ "$os" = "darwin" ]; then
|
||||
download_url="https://github.com/zen-browser/desktop/releases/download/$target_release_name/zen.macos-universal.dmg"
|
||||
else
|
||||
download_url="https://github.com/zen-browser/desktop/releases/download/$target_release_name/zen.linux-$arch.tar.xz"
|
||||
fi
|
||||
|
||||
prefetch_output=$(nix store prefetch-file --unpack --hash-type sha256 --json "$download_url")
|
||||
if [ "$os" = "darwin" ]; then
|
||||
prefetch_output=$(nix store prefetch-file --hash-type sha256 --json "$download_url")
|
||||
else
|
||||
prefetch_output=$(nix store prefetch-file --unpack --hash-type sha256 --json "$download_url")
|
||||
fi
|
||||
sha256=$(echo "$prefetch_output" | jq -r '.hash')
|
||||
|
||||
entry_name="$version_name"
|
||||
@@ -205,12 +221,16 @@ update_version() {
|
||||
echo "Release $release_name already exists, skipping creation..."
|
||||
fi
|
||||
|
||||
get_twilight_release_artifact_meta_from_zen_repo "$arch" |
|
||||
get_twilight_release_artifact_meta_from_zen_repo "$arch" "$os" |
|
||||
while read -r line; do
|
||||
artifact_id=$(echo "$line" | cut -d' ' -f1)
|
||||
artifact_name=$(echo "$line" | cut -d' ' -f2)
|
||||
|
||||
self_download_url="https://github.com/0xc000022070/zen-browser-flake/releases/download/$release_name/zen.linux-$arch.tar.xz"
|
||||
if [ "$os" = "darwin" ]; then
|
||||
self_download_url="https://github.com/0xc000022070/zen-browser-flake/releases/download/$release_name/zen.macos-universal.dmg"
|
||||
else
|
||||
self_download_url="https://github.com/0xc000022070/zen-browser-flake/releases/download/$release_name/zen.linux-$arch.tar.xz"
|
||||
fi
|
||||
|
||||
if ! gh release --repo="$flake_repo_location" view "$release_name" | grep "$artifact_name" >/dev/null; then
|
||||
echo "[downloading] An artifact $artifact_name doesn't exists in $release_name"
|
||||
@@ -225,12 +245,12 @@ update_version() {
|
||||
echo "[skipping] An artifact $artifact_name already exists in $release_name @ following link: $self_download_url"
|
||||
fi
|
||||
|
||||
jq ".[\"twilight\"][\"$arch-linux\"] = {\"version\":\"$semver\",\"sha1\":\"$remote_sha1\",\"url\":\"$self_download_url\",\"sha256\":\"$sha256\"}" <sources.json >sources.json.tmp
|
||||
jq ".[\"twilight\"][\"$arch-$os\"] = {\"version\":\"$semver\",\"sha1\":\"$remote_sha1\",\"url\":\"$self_download_url\",\"sha256\":\"$sha256\"}" <sources.json >sources.json.tmp
|
||||
mv sources.json.tmp sources.json
|
||||
done
|
||||
fi
|
||||
|
||||
jq ".[\"$entry_name\"][\"$arch-linux\"] = {\"version\":\"$semver\",\"sha1\":\"$remote_sha1\",\"url\":\"$download_url\",\"sha256\":\"$sha256\"}" <sources.json >sources.json.tmp
|
||||
jq ".[\"$entry_name\"][\"$arch-$os\"] = {\"version\":\"$semver\",\"sha1\":\"$remote_sha1\",\"url\":\"$download_url\",\"sha256\":\"$sha256\"}" <sources.json >sources.json.tmp
|
||||
mv sources.json.tmp sources.json
|
||||
|
||||
echo "$version_name was updated to $semver"
|
||||
@@ -265,10 +285,12 @@ update_version() {
|
||||
main() {
|
||||
set -e
|
||||
|
||||
update_version "beta" "x86_64"
|
||||
update_version "beta" "aarch64"
|
||||
update_version "twilight" "x86_64"
|
||||
update_version "twilight" "aarch64"
|
||||
update_version "beta" "x86_64" "linux"
|
||||
update_version "beta" "aarch64" "linux"
|
||||
update_version "beta" "aarch64" "darwin"
|
||||
update_version "twilight" "x86_64" "linux"
|
||||
update_version "twilight" "aarch64" "linux"
|
||||
update_version "twilight" "aarch64" "darwin"
|
||||
|
||||
if $only_check && $ci; then
|
||||
echo "should_update=false" >>"$GITHUB_OUTPUT"
|
||||
|
||||
85
package.nix
85
package.nix
@@ -18,6 +18,7 @@
|
||||
pciutils,
|
||||
pipewire,
|
||||
adwaita-icon-theme,
|
||||
undmg,
|
||||
writeText,
|
||||
patchelfUnstable, # have to use patchelfUnstable to support --no-clobber-old-sections
|
||||
applicationName ?
|
||||
@@ -39,6 +40,7 @@
|
||||
mozillaPlatforms = {
|
||||
x86_64-linux = "linux-x86_64";
|
||||
aarch64-linux = "linux-aarch64";
|
||||
aarch64-darwin = "darwin-aarch64";
|
||||
};
|
||||
|
||||
firefoxPolicies =
|
||||
@@ -48,36 +50,83 @@
|
||||
policiesJson = writeText "firefox-policies.json" (builtins.toJSON {policies = firefoxPolicies;});
|
||||
|
||||
pname = "zen-${name}-bin-unwrapped";
|
||||
|
||||
installDarwin = ''
|
||||
mkdir -p "$out/Applications" "$out/bin"
|
||||
cp -r *.app "$out/Applications/${applicationName}.app"
|
||||
ln -s zen "$out/Applications/${applicationName}.app/Contents/MacOS/${binaryName}"
|
||||
|
||||
cat > "$out/bin/${binaryName}" << EOF
|
||||
#!/bin/bash
|
||||
exec /usr/bin/open -na "$out/Applications/${applicationName}.app" --args "\$@"
|
||||
EOF
|
||||
|
||||
chmod +x "$out/bin/${binaryName}"
|
||||
ln -s "$out/bin/${binaryName}" "$out/bin/zen"
|
||||
'';
|
||||
|
||||
installLinux = ''
|
||||
# Linux tarball installation
|
||||
mkdir -p "$prefix/lib/${libName}"
|
||||
cp -r "$src"/* "$prefix/lib/${libName}"
|
||||
|
||||
mkdir -p "$out/bin"
|
||||
ln -s "$prefix/lib/${libName}/zen" "$out/bin/${binaryName}"
|
||||
ln -s "$out/bin/${binaryName}" "$out/bin/zen"
|
||||
|
||||
install -D $desktopSrc/${desktopFile} $out/share/applications/${desktopFile}
|
||||
|
||||
mkdir -p "$out/lib/${libName}/distribution"
|
||||
ln -s ${policiesJson} "$out/lib/${libName}/distribution/policies.json"
|
||||
|
||||
install -D $src/browser/chrome/icons/default/default16.png $out/share/icons/hicolor/16x16/apps/zen-${name}.png
|
||||
install -D $src/browser/chrome/icons/default/default32.png $out/share/icons/hicolor/32x32/apps/zen-${name}.png
|
||||
install -D $src/browser/chrome/icons/default/default48.png $out/share/icons/hicolor/48x48/apps/zen-${name}.png
|
||||
install -D $src/browser/chrome/icons/default/default64.png $out/share/icons/hicolor/64x64/apps/zen-${name}.png
|
||||
install -D $src/browser/chrome/icons/default/default128.png $out/share/icons/hicolor/128x128/apps/zen-${name}.png
|
||||
'';
|
||||
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit pname;
|
||||
inherit (variant) version;
|
||||
|
||||
src = builtins.fetchTarball {inherit (variant) url sha256;};
|
||||
src = if stdenv.hostPlatform.isDarwin
|
||||
then builtins.fetchurl { inherit (variant) url sha256; }
|
||||
else builtins.fetchTarball { inherit (variant) url sha256; };
|
||||
|
||||
sourceRoot = lib.optionalString stdenv.hostPlatform.isDarwin ".";
|
||||
|
||||
desktopSrc = ./assets/desktop;
|
||||
|
||||
nativeBuildInputs = [
|
||||
nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [
|
||||
wrapGAppsHook3
|
||||
autoPatchelfHook
|
||||
patchelfUnstable
|
||||
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
undmg
|
||||
];
|
||||
buildInputs = [
|
||||
|
||||
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
|
||||
gtk3
|
||||
adwaita-icon-theme
|
||||
alsa-lib
|
||||
dbus-glib
|
||||
libXtst
|
||||
];
|
||||
runtimeDependencies = [
|
||||
|
||||
runtimeDependencies = lib.optionals stdenv.hostPlatform.isLinux [
|
||||
curl
|
||||
libva.out
|
||||
pciutils
|
||||
libGL
|
||||
];
|
||||
appendRunpaths = [
|
||||
|
||||
appendRunpaths = lib.optionals stdenv.hostPlatform.isLinux [
|
||||
"${libGL}/lib"
|
||||
"${pipewire}/lib"
|
||||
];
|
||||
|
||||
# Firefox uses "relrhack" to manually process relocations from a fixed offset
|
||||
patchelfFlags = ["--no-clobber-old-sections"];
|
||||
|
||||
@@ -87,26 +136,9 @@ in
|
||||
)
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p "$prefix/lib/${libName}"
|
||||
cp -r "$src"/* "$prefix/lib/${libName}"
|
||||
|
||||
mkdir -p "$out/bin"
|
||||
ln -s "$prefix/lib/${libName}/zen" "$out/bin/${binaryName}"
|
||||
# ! twilight and beta could collide if both are installed
|
||||
ln -s "$out/bin/${binaryName}" "$out/bin/zen"
|
||||
|
||||
install -D $desktopSrc/${desktopFile} $out/share/applications/${desktopFile}
|
||||
|
||||
mkdir -p "$out/lib/${libName}/distribution"
|
||||
ln -s ${policiesJson} "$out/lib/${libName}/distribution/policies.json"
|
||||
|
||||
install -D $src/browser/chrome/icons/default/default16.png $out/share/icons/hicolor/16x16/apps/zen-${name}.png
|
||||
install -D $src/browser/chrome/icons/default/default32.png $out/share/icons/hicolor/32x32/apps/zen-${name}.png
|
||||
install -D $src/browser/chrome/icons/default/default48.png $out/share/icons/hicolor/48x48/apps/zen-${name}.png
|
||||
install -D $src/browser/chrome/icons/default/default64.png $out/share/icons/hicolor/64x64/apps/zen-${name}.png
|
||||
install -D $src/browser/chrome/icons/default/default128.png $out/share/icons/hicolor/128x128/apps/zen-${name}.png
|
||||
'';
|
||||
installPhase = if stdenv.hostPlatform.isDarwin
|
||||
then installDarwin
|
||||
else installLinux;
|
||||
|
||||
passthru = {
|
||||
inherit applicationName binaryName libName;
|
||||
@@ -123,8 +155,7 @@ in
|
||||
changelog = "https://github.com/zen-browser/desktop/releases";
|
||||
sourceProvenance = with lib.sourceTypes; [binaryNativeCode];
|
||||
platforms = builtins.attrNames mozillaPlatforms;
|
||||
broken = stdenv.hostPlatform.isDarwin;
|
||||
hydraPlatforms = [];
|
||||
mainProgram = binaryName;
|
||||
};
|
||||
}
|
||||
}
|
||||
18
sources.json
18
sources.json
@@ -11,6 +11,12 @@
|
||||
"sha1": "19fbad748ca8fc8b6673d4be17534fde8ad877ff",
|
||||
"url": "https://github.com/zen-browser/desktop/releases/download/1.14.7b/zen.linux-aarch64.tar.xz",
|
||||
"sha256": "sha256-Hc9dPGOv68+cRsdT5nOJbRmbTmZWXvPiIv7yFdJ9ngA="
|
||||
},
|
||||
"aarch64-darwin": {
|
||||
"version": "1.14.7b",
|
||||
"sha1": "19fbad748ca8fc8b6673d4be17534fde8ad877ff",
|
||||
"url": "https://github.com/zen-browser/desktop/releases/download/1.14.7b/zen.macos-universal.dmg",
|
||||
"sha256": "sha256-uu8BPOcYPZBrAzHrl0VriVeilgJ9y9AXT/Xaar6S/fc="
|
||||
}
|
||||
},
|
||||
"twilight": {
|
||||
@@ -25,6 +31,12 @@
|
||||
"sha1": "null",
|
||||
"url": "https://github.com/0xc000022070/zen-browser-flake/releases/download/1.15t-1753498188/zen.linux-aarch64.tar.xz",
|
||||
"sha256": "sha256-lmVXK6km/25GzcyN9Pvkwvm6+ejbYVwEHRH+ifRQ4xM="
|
||||
},
|
||||
"aarch64-darwin": {
|
||||
"version": "1.15t",
|
||||
"sha1": "null",
|
||||
"url": "https://github.com/zen-browser/desktop/releases/download/twilight/zen.macos-universal.dmg",
|
||||
"sha256": "sha256-hFozFxbb/HWPjbhg6i2nV60ccpDC8lTONFT7e/+3Pfg="
|
||||
}
|
||||
},
|
||||
"twilight-official": {
|
||||
@@ -39,6 +51,12 @@
|
||||
"sha1": "null",
|
||||
"url": "https://github.com/zen-browser/desktop/releases/download/twilight/zen.linux-aarch64.tar.xz",
|
||||
"sha256": "sha256-lmVXK6km/25GzcyN9Pvkwvm6+ejbYVwEHRH+ifRQ4xM="
|
||||
},
|
||||
"aarch64-darwin": {
|
||||
"version": "1.15t",
|
||||
"sha1": "null",
|
||||
"url": "https://github.com/zen-browser/desktop/releases/download/twilight/zen.macos-universal.dmg",
|
||||
"sha256": "sha256-hFozFxbb/HWPjbhg6i2nV60ccpDC8lTONFT7e/+3Pfg="
|
||||
}
|
||||
},
|
||||
"twilight_metadata": {
|
||||
|
||||
Reference in New Issue
Block a user