nixpkgs/pkgs/applications/networking/browsers/brave/default.nix

145 lines
3.4 KiB
Nix
Raw Normal View History

2018-10-04 12:52:14 +01:00
{ stdenv, lib, fetchurl,
dpkg,
alsaLib,
at-spi2-atk,
atk,
cairo,
cups,
dbus,
expat,
fontconfig,
freetype,
gdk_pixbuf,
glib,
gnome2,
gtk3,
libuuid,
libX11,
libXcomposite,
libXcursor,
libXdamage,
libXext,
libXfixes,
libXi,
libXrandr,
libXrender,
libXScrnSaver,
libXtst,
nspr,
nss,
pango,
udev,
xorg,
2018-11-03 12:01:27 +00:00
zlib,
xdg_utils
2018-10-04 12:52:14 +01:00
}:
let rpath = lib.makeLibraryPath [
alsaLib
at-spi2-atk
atk
cairo
cups
dbus
expat
fontconfig
freetype
gdk_pixbuf
glib
gnome2.GConf
gtk3
libuuid
libX11
libXcomposite
libXcursor
libXdamage
libXext
libXfixes
libXi
libXrandr
libXrender
libXScrnSaver
libXtst
nspr
nss
pango
udev
xorg.libxcb
zlib
2018-11-03 12:01:27 +00:00
xdg_utils
2018-10-04 12:52:14 +01:00
];
in stdenv.mkDerivation rec {
name = "brave";
2018-11-03 12:01:27 +00:00
version = "0.56.12";
2018-10-04 12:52:14 +01:00
src = fetchurl {
2018-11-03 12:01:27 +00:00
url = "https://github.com/brave/brave-browser/releases/download/v${version}/brave-browser_${version}_amd64.deb";
sha256 = "1pvablwchpsm1fdhfp9kr2912yv4812r8prv5fn799qpflzxvyai";
2018-10-04 12:52:14 +01:00
};
2018-11-03 12:01:27 +00:00
dontConfigure = true;
dontBuild = true;
dontPatchELF = true;
2018-10-04 12:52:14 +01:00
nativeBuildInputs = [ dpkg ];
2018-11-03 12:01:27 +00:00
unpackPhase = "dpkg-deb --fsys-tarfile $src | tar -x --no-same-permissions --no-same-owner";
2018-10-04 12:52:14 +01:00
installPhase = ''
mkdir -p $out
cp -R usr/* $out
2018-11-03 12:01:27 +00:00
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
2018-10-04 12:52:14 +01:00
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
2018-11-03 12:01:27 +00:00
--set-rpath "${rpath}" $out/opt/brave.com/brave/brave
# Fix paths
substituteInPlace $out/share/applications/brave-browser.desktop \
--replace /usr/bin/brave-browser $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" "22" "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
2018-10-04 12:52:14 +01:00
'';
meta = with stdenv.lib; {
homepage = "https://brave.com/";
description = "Privacy-oriented browser for Desktop and Laptop computers";
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.
'';
license = licenses.mpl20;
maintainers = [ maintainers.uskudnik ];
platforms = [ "x86_64-linux" ];
};
}