mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 23:13:19 +00:00
Merge pull request #298042 from itsOnly1Jah/brave
Brave: add arm64 support
This commit is contained in:
commit
5cb7527b4a
@ -1,214 +1,21 @@
|
||||
{ lib, stdenv, fetchurl, wrapGAppsHook, makeWrapper
|
||||
, alsa-lib
|
||||
, at-spi2-atk
|
||||
, at-spi2-core
|
||||
, atk
|
||||
, cairo
|
||||
, cups
|
||||
, dbus
|
||||
, dpkg
|
||||
, expat
|
||||
, fontconfig
|
||||
, freetype
|
||||
, gdk-pixbuf
|
||||
, glib
|
||||
, gnome
|
||||
, gsettings-desktop-schemas
|
||||
, gtk3
|
||||
, gtk4
|
||||
, libX11
|
||||
, libXScrnSaver
|
||||
, libXcomposite
|
||||
, libXcursor
|
||||
, libXdamage
|
||||
, libXext
|
||||
, libXfixes
|
||||
, libXi
|
||||
, libXrandr
|
||||
, libXrender
|
||||
, libXtst
|
||||
, libdrm
|
||||
, libkrb5
|
||||
, libuuid
|
||||
, libxkbcommon
|
||||
, libxshmfence
|
||||
, mesa
|
||||
, nspr
|
||||
, nss
|
||||
, pango
|
||||
, pipewire
|
||||
, snappy
|
||||
, udev
|
||||
, wayland
|
||||
, xdg-utils
|
||||
, coreutils
|
||||
, xorg
|
||||
, zlib
|
||||
# Expression generated by update.sh; do not edit it by hand!
|
||||
{ stdenv, callPackage }:
|
||||
|
||||
# command line arguments which are always set e.g "--disable-gpu"
|
||||
, commandLineArgs ? ""
|
||||
|
||||
# Necessary for USB audio devices.
|
||||
, pulseSupport ? stdenv.isLinux
|
||||
, libpulseaudio
|
||||
|
||||
# For GPU acceleration support on Wayland (without the lib it doesn't seem to work)
|
||||
, libGL
|
||||
|
||||
# For video acceleration via VA-API (--enable-features=VaapiVideoDecoder,VaapiVideoEncoder)
|
||||
, libvaSupport ? stdenv.isLinux
|
||||
, libva
|
||||
, enableVideoAcceleration ? libvaSupport
|
||||
|
||||
# For Vulkan support (--enable-features=Vulkan); disabled by default as it seems to break VA-API
|
||||
, vulkanSupport ? false
|
||||
, addOpenGLRunpath
|
||||
, enableVulkan ? vulkanSupport
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) optional optionals makeLibraryPath makeSearchPathOutput makeBinPath
|
||||
optionalString strings escapeShellArg;
|
||||
|
||||
deps = [
|
||||
alsa-lib at-spi2-atk at-spi2-core atk cairo cups dbus expat
|
||||
fontconfig freetype gdk-pixbuf glib gtk3 gtk4 libdrm libX11 libGL
|
||||
libxkbcommon libXScrnSaver libXcomposite libXcursor libXdamage
|
||||
libXext libXfixes libXi libXrandr libXrender libxshmfence
|
||||
libXtst libuuid mesa nspr nss pango pipewire udev wayland
|
||||
xorg.libxcb zlib snappy libkrb5
|
||||
]
|
||||
++ optional pulseSupport libpulseaudio
|
||||
++ optional libvaSupport libva;
|
||||
|
||||
rpath = makeLibraryPath deps + ":" + makeSearchPathOutput "lib" "lib64" deps;
|
||||
binpath = makeBinPath deps;
|
||||
|
||||
enableFeatures = optionals enableVideoAcceleration [ "VaapiVideoDecoder" "VaapiVideoEncoder" ]
|
||||
++ optional enableVulkan "Vulkan";
|
||||
|
||||
disableFeatures = [ "OutdatedBuildDetector" ] # disable automatic updates
|
||||
# The feature disable is needed for VAAPI to work correctly: https://github.com/brave/brave-browser/issues/20935
|
||||
++ optionals enableVideoAcceleration [ "UseChromeOSDirectVideoDecoder" ];
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "brave";
|
||||
version = "1.64.113";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/brave/brave-browser/releases/download/v${version}/brave-browser_${version}_amd64.deb";
|
||||
hash = "sha256-T0uVq1yxDXNi6x9ot5bs3NRaOQ+RwBThvULS6EZ+Bdg=";
|
||||
};
|
||||
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
dontPatchELF = true;
|
||||
doInstallCheck = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
dpkg
|
||||
(wrapGAppsHook.override { inherit makeWrapper; })
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
# needed for GSETTINGS_SCHEMAS_PATH
|
||||
glib gsettings-desktop-schemas gtk3 gtk4
|
||||
|
||||
# needed for XDG_ICON_DIRS
|
||||
gnome.adwaita-icon-theme
|
||||
];
|
||||
|
||||
unpackPhase = "dpkg-deb --fsys-tarfile $src | tar -x --no-same-permissions --no-same-owner";
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out $out/bin
|
||||
|
||||
cp -R usr/share $out
|
||||
cp -R opt/ $out/opt
|
||||
|
||||
export BINARYWRAPPER=$out/opt/brave.com/brave/brave-browser
|
||||
|
||||
# Fix path to bash in $BINARYWRAPPER
|
||||
substituteInPlace $BINARYWRAPPER \
|
||||
--replace /bin/bash ${stdenv.shell}
|
||||
|
||||
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
|
||||
|
||||
# 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")
|
||||
|
||||
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
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
preFixup = ''
|
||||
# Add command line args to wrapGApp.
|
||||
gappsWrapperArgs+=(
|
||||
--prefix LD_LIBRARY_PATH : ${rpath}
|
||||
--prefix PATH : ${binpath}
|
||||
--suffix PATH : ${lib.makeBinPath [ xdg-utils coreutils ]}
|
||||
${optionalString (enableFeatures != []) ''
|
||||
--add-flags "--enable-features=${strings.concatStringsSep "," enableFeatures}\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+,WaylandWindowDecorations}}"
|
||||
''}
|
||||
${optionalString (disableFeatures != []) ''
|
||||
--add-flags "--disable-features=${strings.concatStringsSep "," disableFeatures}"
|
||||
''}
|
||||
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto}}"
|
||||
${optionalString vulkanSupport ''
|
||||
--prefix XDG_DATA_DIRS : "${addOpenGLRunpath.driverLink}/share"
|
||||
''}
|
||||
--add-flags ${escapeShellArg commandLineArgs}
|
||||
)
|
||||
'';
|
||||
|
||||
installCheckPhase = ''
|
||||
# Bypass upstream wrapper which suppresses errors
|
||||
$out/opt/brave.com/brave/brave --version
|
||||
'';
|
||||
|
||||
passthru.updateScript = ./update.sh;
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://brave.com/";
|
||||
description = "Privacy-oriented browser for Desktop and Laptop computers";
|
||||
changelog = "https://github.com/brave/brave-browser/blob/master/CHANGELOG_DESKTOP.md#" + replaceStrings [ "." ] [ "" ] version;
|
||||
longDescription = ''
|
||||
Brave browser blocks the ads and trackers that slow you down,
|
||||
chew up your bandwidth, and invade your privacy. Brave lets you
|
||||
contribute to your favorite creators automatically.
|
||||
'';
|
||||
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
|
||||
license = licenses.mpl20;
|
||||
maintainers = with maintainers; [ uskudnik rht jefflabonte nasirhm buckley310 ];
|
||||
platforms = [ "x86_64-linux" ];
|
||||
mainProgram = "brave";
|
||||
};
|
||||
}
|
||||
if stdenv.isAarch64 then
|
||||
callPackage ./make-brave.nix { } {
|
||||
pname = "brave";
|
||||
version = "1.64.116";
|
||||
url = "https://github.com/brave/brave-browser/releases/download/v1.64.116/brave-browser_1.64.116_arm64.deb";
|
||||
hash = "sha256-XC3GnutiTYdCOJPegj8MRYC5dRrBoKBg4k50ZFrlj4E=";
|
||||
platform = "aarch64-linux";
|
||||
}
|
||||
else if stdenv.isx86_64 then
|
||||
callPackage ./make-brave.nix { } {
|
||||
pname = "brave";
|
||||
version = "1.64.116";
|
||||
url = "https://github.com/brave/brave-browser/releases/download/v1.64.116/brave-browser_1.64.116_amd64.deb";
|
||||
hash = "sha256-mnvFPfZu44TZGdUb+AxaJbecQrXkIzJkYvB4GO55uv0=";
|
||||
platform = "x86_64-linux";
|
||||
}
|
||||
else
|
||||
throw "Unsupported platform."
|
||||
|
218
pkgs/applications/networking/browsers/brave/make-brave.nix
Normal file
218
pkgs/applications/networking/browsers/brave/make-brave.nix
Normal file
@ -0,0 +1,218 @@
|
||||
{ lib, stdenv, fetchurl, wrapGAppsHook, makeWrapper
|
||||
, alsa-lib
|
||||
, at-spi2-atk
|
||||
, at-spi2-core
|
||||
, atk
|
||||
, cairo
|
||||
, cups
|
||||
, dbus
|
||||
, dpkg
|
||||
, expat
|
||||
, fontconfig
|
||||
, freetype
|
||||
, gdk-pixbuf
|
||||
, glib
|
||||
, gnome
|
||||
, gsettings-desktop-schemas
|
||||
, gtk3
|
||||
, gtk4
|
||||
, libX11
|
||||
, libXScrnSaver
|
||||
, libXcomposite
|
||||
, libXcursor
|
||||
, libXdamage
|
||||
, libXext
|
||||
, libXfixes
|
||||
, libXi
|
||||
, libXrandr
|
||||
, libXrender
|
||||
, libXtst
|
||||
, libdrm
|
||||
, libkrb5
|
||||
, libuuid
|
||||
, libxkbcommon
|
||||
, libxshmfence
|
||||
, mesa
|
||||
, nspr
|
||||
, nss
|
||||
, pango
|
||||
, pipewire
|
||||
, snappy
|
||||
, udev
|
||||
, wayland
|
||||
, xdg-utils
|
||||
, coreutils
|
||||
, xorg
|
||||
, zlib
|
||||
|
||||
# command line arguments which are always set e.g "--disable-gpu"
|
||||
, commandLineArgs ? ""
|
||||
|
||||
# Necessary for USB audio devices.
|
||||
, pulseSupport ? stdenv.isLinux
|
||||
, libpulseaudio
|
||||
|
||||
# For GPU acceleration support on Wayland (without the lib it doesn't seem to work)
|
||||
, libGL
|
||||
|
||||
# For video acceleration via VA-API (--enable-features=VaapiVideoDecoder,VaapiVideoEncoder)
|
||||
, libvaSupport ? stdenv.isLinux
|
||||
, libva
|
||||
, enableVideoAcceleration ? libvaSupport
|
||||
|
||||
# For Vulkan support (--enable-features=Vulkan); disabled by default as it seems to break VA-API
|
||||
, vulkanSupport ? false
|
||||
, addOpenGLRunpath
|
||||
, enableVulkan ? vulkanSupport
|
||||
}:
|
||||
|
||||
{ pname
|
||||
, version
|
||||
, hash
|
||||
, url
|
||||
, platform
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) optional optionals makeLibraryPath makeSearchPathOutput makeBinPath
|
||||
optionalString strings escapeShellArg;
|
||||
|
||||
deps = [
|
||||
alsa-lib at-spi2-atk at-spi2-core atk cairo cups dbus expat
|
||||
fontconfig freetype gdk-pixbuf glib gtk3 gtk4 libdrm libX11 libGL
|
||||
libxkbcommon libXScrnSaver libXcomposite libXcursor libXdamage
|
||||
libXext libXfixes libXi libXrandr libXrender libxshmfence
|
||||
libXtst libuuid mesa nspr nss pango pipewire udev wayland
|
||||
xorg.libxcb zlib snappy libkrb5
|
||||
]
|
||||
++ optional pulseSupport libpulseaudio
|
||||
++ optional libvaSupport libva;
|
||||
|
||||
rpath = makeLibraryPath deps + ":" + makeSearchPathOutput "lib" "lib64" deps;
|
||||
binpath = makeBinPath deps;
|
||||
|
||||
enableFeatures = optionals enableVideoAcceleration [ "VaapiVideoDecoder" "VaapiVideoEncoder" ]
|
||||
++ optional enableVulkan "Vulkan";
|
||||
|
||||
disableFeatures = [ "OutdatedBuildDetector" ] # disable automatic updates
|
||||
# The feature disable is needed for VAAPI to work correctly: https://github.com/brave/brave-browser/issues/20935
|
||||
++ optionals enableVideoAcceleration [ "UseChromeOSDirectVideoDecoder" ];
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit pname version;
|
||||
|
||||
src = fetchurl {
|
||||
inherit url hash;
|
||||
};
|
||||
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
dontPatchELF = true;
|
||||
doInstallCheck = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
dpkg
|
||||
(wrapGAppsHook.override { inherit makeWrapper; })
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
# needed for GSETTINGS_SCHEMAS_PATH
|
||||
glib gsettings-desktop-schemas gtk3 gtk4
|
||||
|
||||
# needed for XDG_ICON_DIRS
|
||||
gnome.adwaita-icon-theme
|
||||
];
|
||||
|
||||
unpackPhase = "dpkg-deb --fsys-tarfile $src | tar -x --no-same-permissions --no-same-owner";
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out $out/bin
|
||||
|
||||
cp -R usr/share $out
|
||||
cp -R opt/ $out/opt
|
||||
|
||||
export BINARYWRAPPER=$out/opt/brave.com/brave/brave-browser
|
||||
|
||||
# Fix path to bash in $BINARYWRAPPER
|
||||
substituteInPlace $BINARYWRAPPER \
|
||||
--replace /bin/bash ${stdenv.shell}
|
||||
|
||||
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
|
||||
|
||||
# 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")
|
||||
|
||||
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
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
preFixup = ''
|
||||
# Add command line args to wrapGApp.
|
||||
gappsWrapperArgs+=(
|
||||
--prefix LD_LIBRARY_PATH : ${rpath}
|
||||
--prefix PATH : ${binpath}
|
||||
--suffix PATH : ${lib.makeBinPath [ xdg-utils coreutils ]}
|
||||
${optionalString (enableFeatures != []) ''
|
||||
--add-flags "--enable-features=${strings.concatStringsSep "," enableFeatures}\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+,WaylandWindowDecorations}}"
|
||||
''}
|
||||
${optionalString (disableFeatures != []) ''
|
||||
--add-flags "--disable-features=${strings.concatStringsSep "," disableFeatures}"
|
||||
''}
|
||||
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto}}"
|
||||
${optionalString vulkanSupport ''
|
||||
--prefix XDG_DATA_DIRS : "${addOpenGLRunpath.driverLink}/share"
|
||||
''}
|
||||
--add-flags ${escapeShellArg commandLineArgs}
|
||||
)
|
||||
'';
|
||||
|
||||
installCheckPhase = ''
|
||||
# Bypass upstream wrapper which suppresses errors
|
||||
$out/opt/brave.com/brave/brave --version
|
||||
'';
|
||||
|
||||
passthru.updateScript = ./update.sh;
|
||||
|
||||
meta = {
|
||||
homepage = "https://brave.com/";
|
||||
description = "Privacy-oriented browser for Desktop and Laptop computers";
|
||||
changelog = "https://github.com/brave/brave-browser/blob/master/CHANGELOG_DESKTOP.md#" + lib.replaceStrings [ "." ] [ "" ] version;
|
||||
longDescription = ''
|
||||
Brave browser blocks the ads and trackers that slow you down,
|
||||
chew up your bandwidth, and invade your privacy. Brave lets you
|
||||
contribute to your favorite creators automatically.
|
||||
'';
|
||||
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
||||
license = lib.licenses.mpl20;
|
||||
maintainers = with lib.maintainers; [ uskudnik rht jefflabonte nasirhm buckley310 ];
|
||||
platforms = [ "aarch64-linux" "x86_64-linux" ];
|
||||
mainProgram = "brave";
|
||||
};
|
||||
}
|
@ -1,5 +1,42 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl gnused common-updater-scripts
|
||||
#!nix-shell -i bash -p curl gnused nix
|
||||
|
||||
version="$(curl -sL https://brave-browser-apt-release.s3.brave.com/dists/stable/main/binary-amd64/Packages | sed -r -n 's/^Version: (.*)/\1/p' | head -n1)"
|
||||
update-source-version brave "$version"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
|
||||
|
||||
latestVersionAarch64="$(curl -sL https://brave-browser-apt-release.s3.brave.com/dists/stable/main/binary-arm64/Packages \
|
||||
| sed -r -n 's/^Version: (.*)/\1/p' | head -n1)"
|
||||
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)
|
||||
)"
|
||||
|
||||
latestVersionAmd64="$(curl -sL https://brave-browser-apt-release.s3.brave.com/dists/stable/main/binary-amd64/Packages \
|
||||
| sed -r -n 's/^Version: (.*)/\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)
|
||||
)"
|
||||
|
||||
cat > $SCRIPT_DIR/default.nix << EOF
|
||||
# Expression generated by update.sh; do not edit it by hand!
|
||||
{ stdenv, callPackage }:
|
||||
|
||||
if stdenv.isAarch64 then
|
||||
callPackage ./make-brave.nix { } {
|
||||
pname = "brave";
|
||||
version = "${latestVersionAarch64}";
|
||||
url = "https://github.com/brave/brave-browser/releases/download/v${latestVersionAarch64}/brave-browser_${latestVersionAarch64}_arm64.deb";
|
||||
hash = "${hashAarch64}";
|
||||
platform = "aarch64-linux";
|
||||
}
|
||||
else if stdenv.isx86_64 then
|
||||
callPackage ./make-brave.nix { } {
|
||||
pname = "brave";
|
||||
version = "${latestVersionAmd64}";
|
||||
url = "https://github.com/brave/brave-browser/releases/download/v${latestVersionAmd64}/brave-browser_${latestVersionAmd64}_amd64.deb";
|
||||
hash = "${hashAmd64}";
|
||||
platform = "x86_64-linux";
|
||||
}
|
||||
else
|
||||
throw "Unsupported platform."
|
||||
EOF
|
||||
|
Loading…
Reference in New Issue
Block a user