1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
{ channel, version, revision, sha256 }:
{ stdenv
, fetchurl
, lib
, binutils-unwrapped
, xz
, gnutar
, file
, glibc
, glib
, nss
, nspr
, atk
, at-spi2-atk
, xorg
, cups
, dbus
, expat
, libdrm
, libxkbcommon
, gtk3
, pango
, cairo
, gdk-pixbuf
, mesa
, alsa-lib
, at-spi2-core
, libuuid
, systemd
, wayland
}:
let
baseName = "microsoft-edge";
shortName = if channel == "stable"
then "msedge"
else "msedge-" + channel;
longName = if channel == "stable"
then baseName
else baseName + "-" + channel;
iconSuffix = if channel == "stable"
then ""
else "_${channel}";
desktopSuffix = if channel == "stable"
then ""
else "-${channel}";
in
stdenv.mkDerivation rec {
name="${baseName}-${channel}-${version}";
src = fetchurl {
url = "https://packages.microsoft.com/repos/edge/pool/main/m/${baseName}-${channel}/${baseName}-${channel}_${version}-${revision}_amd64.deb";
inherit sha256;
};
unpackCmd = "${binutils-unwrapped}/bin/ar p $src data.tar.xz | ${xz}/bin/xz -dc | ${gnutar}/bin/tar -xf -";
sourceRoot = ".";
dontPatch = true;
dontConfigure = true;
dontPatchELF = true;
buildPhase = let
libPath = {
msedge = lib.makeLibraryPath [
glibc glib nss nspr atk at-spi2-atk xorg.libX11
xorg.libxcb cups.lib dbus.lib expat libdrm
xorg.libXcomposite xorg.libXdamage xorg.libXext
xorg.libXfixes xorg.libXrandr libxkbcommon
gtk3 pango cairo gdk-pixbuf mesa
alsa-lib at-spi2-core xorg.libxshmfence systemd wayland
];
naclHelper = lib.makeLibraryPath [
glib nspr atk libdrm xorg.libxcb mesa xorg.libX11
xorg.libXext dbus.lib libxkbcommon
];
libwidevinecdm = lib.makeLibraryPath [
glib nss nspr
];
libGLESv2 = lib.makeLibraryPath [
xorg.libX11 xorg.libXext xorg.libxcb wayland
];
libsmartscreen = lib.makeLibraryPath [
libuuid stdenv.cc.cc.lib
];
libsmartscreenn = lib.makeLibraryPath [
libuuid
];
liboneauth = lib.makeLibraryPath [
libuuid xorg.libX11
];
};
in ''
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${libPath.msedge}" \
opt/microsoft/${shortName}/msedge
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
opt/microsoft/${shortName}/msedge-sandbox
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
opt/microsoft/${shortName}/msedge_crashpad_handler
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${libPath.naclHelper}" \
opt/microsoft/${shortName}/nacl_helper
patchelf \
--set-rpath "${libPath.libwidevinecdm}" \
opt/microsoft/${shortName}/WidevineCdm/_platform_specific/linux_x64/libwidevinecdm.so
patchelf \
--set-rpath "${libPath.libGLESv2}" \
opt/microsoft/${shortName}/libGLESv2.so
patchelf \
--set-rpath "${libPath.libsmartscreen}" \
opt/microsoft/${shortName}/libsmartscreen.so
patchelf \
--set-rpath "${libPath.libsmartscreenn}" \
opt/microsoft/${shortName}/libsmartscreenn.so
patchelf \
--set-rpath "${libPath.liboneauth}" \
opt/microsoft/${shortName}/liboneauth.so
'';
installPhase = ''
mkdir -p $out
cp -R opt usr/bin usr/share $out
${if channel == "stable"
then ""
else "ln -sf $out/opt/microsoft/${shortName}/${baseName}-${channel} $out/opt/microsoft/${shortName}/${baseName}"}
ln -sf $out/opt/microsoft/${shortName}/${longName} $out/bin/${longName}
rm -rf $out/share/doc
rm -rf $out/opt/microsoft/${shortName}/cron
for icon in '16' '24' '32' '48' '64' '128' '256'
do
${ "icon_source=$out/opt/microsoft/${shortName}/product_logo_\${icon}${iconSuffix}.png" }
${ "icon_target=$out/share/icons/hicolor/\${icon}x\${icon}/apps" }
mkdir -p $icon_target
cp $icon_source $icon_target/microsoft-edge${desktopSuffix}.png
done
substituteInPlace $out/share/applications/${longName}.desktop \
--replace /usr/bin/${baseName}-${channel} $out/bin/${longName}
substituteInPlace $out/share/gnome-control-center/default-apps/${longName}.xml \
--replace /opt/microsoft/${shortName} $out/opt/microsoft/${shortName}
substituteInPlace $out/share/menu/${longName}.menu \
--replace /opt/microsoft/${shortName} $out/opt/microsoft/${shortName}
substituteInPlace $out/opt/microsoft/${shortName}/xdg-mime \
--replace "''${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" "''${XDG_DATA_DIRS:-/run/current-system/sw/share}" \
--replace "xdg_system_dirs=/usr/local/share/:/usr/share/" "xdg_system_dirs=/run/current-system/sw/share/" \
--replace /usr/bin/file ${file}/bin/file
substituteInPlace $out/opt/microsoft/${shortName}/default-app-block \
--replace /opt/microsoft/${shortName} $out/opt/microsoft/${shortName}
substituteInPlace $out/opt/microsoft/${shortName}/xdg-settings \
--replace "''${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" "''${XDG_DATA_DIRS:-/run/current-system/sw/share}" \
--replace "''${XDG_CONFIG_DIRS:-/etc/xdg}" "''${XDG_CONFIG_DIRS:-/run/current-system/sw/etc/xdg}"
'';
meta = with lib; {
homepage = "https://www.microsoft.com/en-us/edge";
description = "The web browser from Microsoft";
license = licenses.unfree;
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
platforms = [ "x86_64-linux" ];
maintainers = with maintainers; [ zanculmarktum kuwii ];
};
}
|