fluffychat: 1.22.1 -> 1.23.0 (#364091)
[NixPkgs.git] / pkgs / by-name / mi / microsoft-edge / package.nix
blobcd3af906cb1b24197bf0e259a64acc0eeaf53f35
2   fetchurl,
3   lib,
4   makeWrapper,
5   patchelf,
6   stdenv,
8   # Linked dynamic libraries.
9   alsa-lib,
10   at-spi2-atk,
11   at-spi2-core,
12   atk,
13   cairo,
14   cups,
15   dbus,
16   expat,
17   fontconfig,
18   freetype,
19   gcc-unwrapped,
20   gdk-pixbuf,
21   glib,
22   gtk3,
23   gtk4,
24   libdrm,
25   libglvnd,
26   libkrb5,
27   libX11,
28   libxcb,
29   libXcomposite,
30   libXcursor,
31   libXdamage,
32   libXext,
33   libXfixes,
34   libXi,
35   libxkbcommon,
36   libXrandr,
37   libXrender,
38   libXScrnSaver,
39   libxshmfence,
40   libXtst,
41   mesa,
42   nspr,
43   nss,
44   pango,
45   pipewire,
46   vulkan-loader,
47   wayland, # ozone/wayland
49   # Command line programs
50   coreutils,
52   # command line arguments which are always set e.g "--disable-gpu"
53   commandLineArgs ? "",
55   # Will crash without.
56   systemd,
58   # Loaded at runtime.
59   libexif,
60   pciutils,
62   # Additional dependencies according to other distros.
63   ## Ubuntu
64   curl,
65   liberation_ttf,
66   util-linux,
67   wget,
68   xdg-utils,
69   ## Arch Linux.
70   flac,
71   harfbuzz,
72   icu,
73   libopus,
74   libpng,
75   snappy,
76   speechd-minimal,
77   ## Gentoo
78   bzip2,
79   libcap,
81   # Necessary for USB audio devices.
82   libpulseaudio,
83   pulseSupport ? true,
85   adwaita-icon-theme,
86   gsettings-desktop-schemas,
88   # For video acceleration via VA-API (--enable-features=VaapiVideoDecoder)
89   libva,
90   libvaSupport ? true,
92   # For Vulkan support (--enable-features=Vulkan)
93   addDriverRunpath,
95   # Edge Specific
96   libuuid,
99 let
101   opusWithCustomModes = libopus.override { withCustomModes = true; };
103   deps =
104     [
105       alsa-lib
106       at-spi2-atk
107       at-spi2-core
108       atk
109       bzip2
110       cairo
111       coreutils
112       cups
113       curl
114       dbus
115       expat
116       flac
117       fontconfig
118       freetype
119       gcc-unwrapped.lib
120       gdk-pixbuf
121       glib
122       harfbuzz
123       icu
124       libcap
125       libdrm
126       liberation_ttf
127       libexif
128       libglvnd
129       libkrb5
130       libpng
131       libX11
132       libxcb
133       libXcomposite
134       libXcursor
135       libXdamage
136       libXext
137       libXfixes
138       libXi
139       libxkbcommon
140       libXrandr
141       libXrender
142       libXScrnSaver
143       libxshmfence
144       libXtst
145       mesa
146       nspr
147       nss
148       opusWithCustomModes
149       pango
150       pciutils
151       pipewire
152       snappy
153       speechd-minimal
154       systemd
155       util-linux
156       vulkan-loader
157       wayland
158       wget
159       libuuid
160     ]
161     ++ lib.optional pulseSupport libpulseaudio
162     ++ lib.optional libvaSupport libva
163     ++ [
164       gtk3
165       gtk4
166     ];
169 stdenv.mkDerivation (finalAttrs: {
170   pname = "microsoft-edge";
171   version = "131.0.2903.70";
173   src = fetchurl {
174     url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_${finalAttrs.version}-1_amd64.deb";
175     hash = "sha256-LcinHmzr3o5ILjGdr8uuiOGWok0J9G/kTdASfYQh/tM=";
176   };
178   # With strictDeps on, some shebangs were not being patched correctly
179   # ie, $out/share/microsoft/msedge/microsoft-edge
180   strictDeps = false;
182   nativeBuildInputs = [
183     makeWrapper
184     patchelf
185   ];
187   buildInputs = [
188     # needed for XDG_ICON_DIRS
189     adwaita-icon-theme
190     glib
191     gtk3
192     gtk4
193     # needed for GSETTINGS_SCHEMAS_PATH
194     gsettings-desktop-schemas
195   ];
197   unpackPhase = ''
198     runHook preUnpack
199     ar x $src
200     tar xf data.tar.xz
201     runHook postUnpack
202   '';
204   rpath = lib.makeLibraryPath deps + ":" + lib.makeSearchPathOutput "lib" "lib64" deps;
205   binpath = lib.makeBinPath deps;
207   installPhase = ''
208     runHook preInstall
210     appname=msedge
211     dist=stable
213     exe=$out/bin/microsoft-edge
215     mkdir -p $out/bin $out/share
216     cp -v -a opt/* $out/share
217     cp -v -a usr/share/* $out/share
219     # replace bundled vulkan-loader
220     rm -v $out/share/microsoft/$appname/libvulkan.so.1
221     ln -v -s -t "$out/share/microsoft/$appname" "${lib.getLib vulkan-loader}/lib/libvulkan.so.1"
223     substituteInPlace $out/share/microsoft/$appname/microsoft-edge \
224       --replace-fail 'CHROME_WRAPPER' 'WRAPPER'
225     substituteInPlace $out/share/applications/microsoft-edge.desktop \
226       --replace-fail /usr/bin/microsoft-edge-$dist $exe
227     substituteInPlace $out/share/gnome-control-center/default-apps/microsoft-edge.xml \
228       --replace-fail /opt/microsoft/msedge $exe
229     substituteInPlace $out/share/menu/microsoft-edge.menu \
230       --replace-fail /opt $out/share \
231       --replace-fail $out/share/microsoft/$appname/microsoft-edge $exe
233     for icon_file in $out/share/microsoft/msedge/product_logo_[0-9]*.png; do
234       num_and_suffix="''${icon_file##*logo_}"
235       if [ $dist = "stable" ]; then
236         icon_size="''${num_and_suffix%.*}"
237       else
238         icon_size="''${num_and_suffix%_*}"
239       fi
240       logo_output_prefix="$out/share/icons/hicolor"
241       logo_output_path="$logo_output_prefix/''${icon_size}x''${icon_size}/apps"
242       mkdir -p "$logo_output_path"
243       mv "$icon_file" "$logo_output_path/microsoft-edge.png"
244     done
246     # "--simulate-outdated-no-au" disables auto updates and browser outdated popup
247     makeWrapper "$out/share/microsoft/$appname/microsoft-edge" "$exe" \
248       --prefix LD_LIBRARY_PATH : "$rpath" \
249       --prefix PATH            : "$binpath" \
250       --suffix PATH            : "${lib.makeBinPath [ xdg-utils ]}" \
251       --prefix XDG_DATA_DIRS   : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH:${addDriverRunpath.driverLink}/share" \
252       --set CHROME_WRAPPER  "microsoft-edge-$dist" \
253       --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
254       --add-flags "--simulate-outdated-no-au='Tue, 31 Dec 2099 23:59:59 GMT'" \
255       --add-flags ${lib.escapeShellArg commandLineArgs}
257     # Make sure that libGL and libvulkan are found by ANGLE libGLESv2.so
258     patchelf --set-rpath $rpath $out/share/microsoft/$appname/lib*GL*
260     # Edge specific set liboneauth
261     patchelf --set-rpath $rpath $out/share/microsoft/$appname/liboneauth.so
263     for elf in $out/share/microsoft/$appname/{msedge,msedge-sandbox,msedge_crashpad_handler}; do
264       patchelf --set-rpath $rpath $elf
265       patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $elf
266     done
268     runHook postInstall
269   '';
271   passthru.updateScript = ./update.py;
273   meta = {
274     changelog = "https://learn.microsoft.com/en-us/deployedge/microsoft-edge-relnote-stable-channel";
275     description = "Web browser from Microsoft";
276     homepage = "https://www.microsoft.com/en-us/edge";
277     license = lib.licenses.unfree;
278     mainProgram = "microsoft-edge";
279     maintainers = with lib.maintainers; [
280       zanculmarktum
281       kuwii
282       rhysmdnz
283     ];
284     platforms = [ "x86_64-linux" ];
285     sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
286   };