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