mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
brave: darwin support, add darwin maintainer (#352880)
This commit is contained in:
commit
4f10285eed
@ -50,6 +50,10 @@
|
||||
xorg,
|
||||
zlib,
|
||||
|
||||
# Darwin dependencies
|
||||
unzip,
|
||||
makeWrapper,
|
||||
|
||||
# command line arguments which are always set e.g "--disable-gpu"
|
||||
commandLineArgs ? "",
|
||||
|
||||
@ -76,7 +80,6 @@
|
||||
version,
|
||||
hash,
|
||||
url,
|
||||
platform,
|
||||
}:
|
||||
|
||||
let
|
||||
@ -161,16 +164,21 @@ stdenv.mkDerivation {
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
dontPatchELF = true;
|
||||
doInstallCheck = true;
|
||||
doInstallCheck = stdenv.hostPlatform.isLinux;
|
||||
|
||||
nativeBuildInputs = [
|
||||
dpkg
|
||||
# override doesn't preserve splicing https://github.com/NixOS/nixpkgs/issues/132651
|
||||
# Has to use `makeShellWrapper` from `buildPackages` even though `makeShellWrapper` from the inputs is spliced because `propagatedBuildInputs` would pick the wrong one because of a different offset.
|
||||
(buildPackages.wrapGAppsHook3.override { makeWrapper = buildPackages.makeShellWrapper; })
|
||||
];
|
||||
nativeBuildInputs =
|
||||
lib.optionals stdenv.hostPlatform.isLinux [
|
||||
dpkg
|
||||
# override doesn't preserve splicing https://github.com/NixOS/nixpkgs/issues/132651
|
||||
# Has to use `makeShellWrapper` from `buildPackages` even though `makeShellWrapper` from the inputs is spliced because `propagatedBuildInputs` would pick the wrong one because of a different offset.
|
||||
(buildPackages.wrapGAppsHook3.override { makeWrapper = buildPackages.makeShellWrapper; })
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
unzip
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
|
||||
# needed for GSETTINGS_SCHEMAS_PATH
|
||||
glib
|
||||
gsettings-desktop-schemas
|
||||
@ -181,57 +189,73 @@ stdenv.mkDerivation {
|
||||
adwaita-icon-theme
|
||||
];
|
||||
|
||||
unpackPhase = "dpkg-deb --fsys-tarfile $src | tar -x --no-same-permissions --no-same-owner";
|
||||
unpackPhase =
|
||||
if stdenv.hostPlatform.isLinux then
|
||||
"dpkg-deb --fsys-tarfile $src | tar -x --no-same-permissions --no-same-owner"
|
||||
else
|
||||
"unzip $src";
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
installPhase =
|
||||
lib.optionalString stdenv.hostPlatform.isLinux ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out $out/bin
|
||||
mkdir -p $out $out/bin
|
||||
|
||||
cp -R usr/share $out
|
||||
cp -R opt/ $out/opt
|
||||
cp -R usr/share $out
|
||||
cp -R opt/ $out/opt
|
||||
|
||||
export BINARYWRAPPER=$out/opt/brave.com/brave/brave-browser
|
||||
export BINARYWRAPPER=$out/opt/brave.com/brave/brave-browser
|
||||
|
||||
# Fix path to bash in $BINARYWRAPPER
|
||||
substituteInPlace $BINARYWRAPPER \
|
||||
--replace /bin/bash ${stdenv.shell}
|
||||
# Fix path to bash in $BINARYWRAPPER
|
||||
substituteInPlace $BINARYWRAPPER \
|
||||
--replace /bin/bash ${stdenv.shell}
|
||||
|
||||
ln -sf $BINARYWRAPPER $out/bin/brave
|
||||
ln -sf $BINARYWRAPPER $out/bin/brave
|
||||
|
||||
for exe in $out/opt/brave.com/brave/{brave,chrome_crashpad_handler}; do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${rpath}" $exe
|
||||
done
|
||||
for exe in $out/opt/brave.com/brave/{brave,chrome_crashpad_handler}; do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${rpath}" $exe
|
||||
done
|
||||
|
||||
# Fix paths
|
||||
substituteInPlace $out/share/applications/brave-browser.desktop \
|
||||
--replace /usr/bin/brave-browser-stable $out/bin/brave
|
||||
substituteInPlace $out/share/gnome-control-center/default-apps/brave-browser.xml \
|
||||
--replace /opt/brave.com $out/opt/brave.com
|
||||
substituteInPlace $out/share/menu/brave-browser.menu \
|
||||
--replace /opt/brave.com $out/opt/brave.com
|
||||
substituteInPlace $out/opt/brave.com/brave/default-app-block \
|
||||
--replace /opt/brave.com $out/opt/brave.com
|
||||
# Fix paths
|
||||
substituteInPlace $out/share/applications/brave-browser.desktop \
|
||||
--replace /usr/bin/brave-browser-stable $out/bin/brave
|
||||
substituteInPlace $out/share/gnome-control-center/default-apps/brave-browser.xml \
|
||||
--replace /opt/brave.com $out/opt/brave.com
|
||||
substituteInPlace $out/share/menu/brave-browser.menu \
|
||||
--replace /opt/brave.com $out/opt/brave.com
|
||||
substituteInPlace $out/opt/brave.com/brave/default-app-block \
|
||||
--replace /opt/brave.com $out/opt/brave.com
|
||||
|
||||
# Correct icons location
|
||||
icon_sizes=("16" "24" "32" "48" "64" "128" "256")
|
||||
# Correct icons location
|
||||
icon_sizes=("16" "24" "32" "48" "64" "128" "256")
|
||||
|
||||
for icon in ''${icon_sizes[*]}
|
||||
do
|
||||
mkdir -p $out/share/icons/hicolor/$icon\x$icon/apps
|
||||
ln -s $out/opt/brave.com/brave/product_logo_$icon.png $out/share/icons/hicolor/$icon\x$icon/apps/brave-browser.png
|
||||
done
|
||||
for icon in ''${icon_sizes[*]}
|
||||
do
|
||||
mkdir -p $out/share/icons/hicolor/$icon\x$icon/apps
|
||||
ln -s $out/opt/brave.com/brave/product_logo_$icon.png $out/share/icons/hicolor/$icon\x$icon/apps/brave-browser.png
|
||||
done
|
||||
|
||||
# Replace xdg-settings and xdg-mime
|
||||
ln -sf ${xdg-utils}/bin/xdg-settings $out/opt/brave.com/brave/xdg-settings
|
||||
ln -sf ${xdg-utils}/bin/xdg-mime $out/opt/brave.com/brave/xdg-mime
|
||||
# Replace xdg-settings and xdg-mime
|
||||
ln -sf ${xdg-utils}/bin/xdg-settings $out/opt/brave.com/brave/xdg-settings
|
||||
ln -sf ${xdg-utils}/bin/xdg-mime $out/opt/brave.com/brave/xdg-mime
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
runHook postInstall
|
||||
''
|
||||
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
runHook preInstall
|
||||
|
||||
preFixup = ''
|
||||
mkdir -p $out/{Applications,bin}
|
||||
|
||||
cp -r "Brave Browser.app" $out/Applications/
|
||||
|
||||
makeWrapper "$out/Applications/Brave Browser.app/Contents/MacOS/Brave Browser" $out/bin/brave
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
preFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
|
||||
# Add command line args to wrapGApp.
|
||||
gappsWrapperArgs+=(
|
||||
--prefix LD_LIBRARY_PATH : ${rpath}
|
||||
@ -286,10 +310,13 @@ stdenv.mkDerivation {
|
||||
jefflabonte
|
||||
nasirhm
|
||||
buckley310
|
||||
matteopacini
|
||||
];
|
||||
platforms = [
|
||||
"aarch64-linux"
|
||||
"x86_64-linux"
|
||||
"aarch64-darwin"
|
||||
"x86_64-darwin"
|
||||
];
|
||||
mainProgram = "brave";
|
||||
};
|
||||
|
@ -14,6 +14,14 @@ let
|
||||
url = "https://github.com/brave/brave-browser/releases/download/v${version}/brave-browser_${version}_amd64.deb";
|
||||
hash = "sha256-fJczTAra+j8+veicz4lIyKSNJyxJK4q9gpZoAyQwkxQ=";
|
||||
};
|
||||
aarch64-darwin = {
|
||||
url = "https://github.com/brave/brave-browser/releases/download/v${version}/brave-v${version}-darwin-arm64.zip";
|
||||
hash = "sha256-kDiZ6NKQ+v1jBEUexItKTCKFsbnOtSzPmGEVWI5JoXI=";
|
||||
};
|
||||
x86_64-darwin = {
|
||||
url = "https://github.com/brave/brave-browser/releases/download/v${version}/brave-v${version}-darwin-x64.zip";
|
||||
hash = "sha256-/yl4k/XvmL7oBW1XU4wVNHfa07Z+XMHYTkkufhDCXUc=";
|
||||
};
|
||||
};
|
||||
|
||||
archive =
|
||||
@ -27,6 +35,5 @@ callPackage ./make-brave.nix (removeAttrs args [ "callPackage" ]) (
|
||||
archive
|
||||
// {
|
||||
inherit pname version;
|
||||
platform = stdenv.system;
|
||||
}
|
||||
)
|
||||
|
@ -5,15 +5,10 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
|
||||
|
||||
latestVersion="$(curl --fail -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/brave/brave-browser/releases/latest" | jq -r '.tag_name' | sed 's/^v//')"
|
||||
|
||||
hashAarch64="$(nix hash to-sri --type sha256 \
|
||||
$(curl -sL https://brave-browser-apt-release.s3.brave.com/dists/stable/main/binary-arm64/Packages \
|
||||
| sed -r -n 's/^SHA256: (.*)/\1/p' | head -n1)
|
||||
)"
|
||||
|
||||
hashAmd64="$(nix hash to-sri --type sha256 \
|
||||
$(curl -sL https://brave-browser-apt-release.s3.brave.com/dists/stable/main/binary-amd64/Packages \
|
||||
| sed -r -n 's/^SHA256: (.*)/\1/p' | head -n1)
|
||||
)"
|
||||
hashAarch64="$(nix-hash --to-sri --type sha256 "$(nix-prefetch-url --type sha256 "https://github.com/brave/brave-browser/releases/download/v${latestVersion}/brave-browser_${latestVersion}_arm64.deb")")"
|
||||
hashAmd64="$(nix-hash --to-sri --type sha256 "$(nix-prefetch-url --type sha256 "https://github.com/brave/brave-browser/releases/download/v${latestVersion}/brave-browser_${latestVersion}_amd64.deb")")"
|
||||
hashAarch64Darwin="$(nix-hash --to-sri --type sha256 "$(nix-prefetch-url --type sha256 "https://github.com/brave/brave-browser/releases/download/v${latestVersion}/brave-v${latestVersion}-darwin-arm64.zip")")"
|
||||
hashAmd64Darwin="$(nix-hash --to-sri --type sha256 "$(nix-prefetch-url --type sha256 "https://github.com/brave/brave-browser/releases/download/v${latestVersion}/brave-v${latestVersion}-darwin-x64.zip")")"
|
||||
|
||||
cat > $SCRIPT_DIR/package.nix << EOF
|
||||
# Expression generated by update.sh; do not edit it by hand!
|
||||
@ -32,6 +27,14 @@ let
|
||||
url = "https://github.com/brave/brave-browser/releases/download/v\${version}/brave-browser_\${version}_amd64.deb";
|
||||
hash = "${hashAmd64}";
|
||||
};
|
||||
aarch64-darwin = {
|
||||
url = "https://github.com/brave/brave-browser/releases/download/v\${version}/brave-v\${version}-darwin-arm64.zip";
|
||||
hash = "${hashAarch64Darwin}";
|
||||
};
|
||||
x86_64-darwin = {
|
||||
url = "https://github.com/brave/brave-browser/releases/download/v\${version}/brave-v\${version}-darwin-x64.zip";
|
||||
hash = "${hashAmd64Darwin}";
|
||||
};
|
||||
};
|
||||
|
||||
archive =
|
||||
|
Loading…
Reference in New Issue
Block a user