microsoft-edge: Mirror google-chrome derivation (#347836)

authored by

Emily Trau and committed by
GitHub
db899cdd c520c086

+331 -291
-197
pkgs/applications/networking/browsers/microsoft-edge/browser.nix
··· 1 - { channel, version, revision, hash }: 2 - 3 - { stdenv 4 - , fetchurl 5 - , lib 6 - , makeWrapper 7 - 8 - , binutils-unwrapped 9 - , xz 10 - , gnutar 11 - , file 12 - 13 - , glibc 14 - , glib 15 - , nss 16 - , nspr 17 - , atk 18 - , at-spi2-atk 19 - , xorg 20 - , cups 21 - , dbus 22 - , expat 23 - , libdrm 24 - , libxkbcommon 25 - , pipewire 26 - , gtk3 27 - , pango 28 - , cairo 29 - , gdk-pixbuf 30 - , mesa 31 - , alsa-lib 32 - , at-spi2-core 33 - , libuuid 34 - , systemd 35 - , wayland 36 - , libGL 37 - 38 - # command line arguments which are always set e.g "--disable-gpu" 39 - , commandLineArgs ? "" 40 - }: 41 - 42 - let 43 - 44 - baseName = "microsoft-edge"; 45 - 46 - shortName = if channel == "stable" 47 - then "msedge" 48 - else "msedge-" + channel; 49 - 50 - longName = if channel == "stable" 51 - then baseName 52 - else baseName + "-" + channel; 53 - 54 - iconSuffix = lib.optionalString (channel != "stable") "_${channel}"; 55 - 56 - desktopSuffix = lib.optionalString (channel != "stable") "-${channel}"; 57 - in 58 - 59 - stdenv.mkDerivation rec { 60 - pname="${baseName}-${channel}"; 61 - inherit version; 62 - 63 - src = fetchurl { 64 - url = "https://packages.microsoft.com/repos/edge/pool/main/m/${baseName}-${channel}/${baseName}-${channel}_${version}-${revision}_amd64.deb"; 65 - inherit hash; 66 - }; 67 - 68 - nativeBuildInputs = [ 69 - makeWrapper 70 - ]; 71 - 72 - unpackCmd = "${binutils-unwrapped}/bin/ar p $src data.tar.xz | ${xz}/bin/xz -dc | ${gnutar}/bin/tar -xf -"; 73 - sourceRoot = "."; 74 - 75 - dontPatch = true; 76 - dontConfigure = true; 77 - dontPatchELF = true; 78 - 79 - buildPhase = let 80 - libPath = { 81 - msedge = lib.makeLibraryPath [ 82 - glibc glib nss nspr atk at-spi2-atk xorg.libX11 83 - xorg.libxcb cups.lib dbus.lib expat libdrm 84 - xorg.libXcomposite xorg.libXdamage xorg.libXext 85 - xorg.libXfixes xorg.libXrandr libxkbcommon 86 - pipewire gtk3 pango cairo gdk-pixbuf mesa 87 - alsa-lib at-spi2-core xorg.libxshmfence systemd wayland 88 - ]; 89 - naclHelper = lib.makeLibraryPath [ 90 - glib nspr atk libdrm xorg.libxcb mesa xorg.libX11 91 - xorg.libXext dbus.lib libxkbcommon 92 - ]; 93 - libwidevinecdm = lib.makeLibraryPath [ 94 - glib nss nspr 95 - ]; 96 - libGLESv2 = lib.makeLibraryPath [ 97 - xorg.libX11 xorg.libXext xorg.libxcb wayland libGL 98 - ]; 99 - liboneauth = lib.makeLibraryPath [ 100 - libuuid xorg.libX11 101 - ]; 102 - }; 103 - in '' 104 - patchelf \ 105 - --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ 106 - --set-rpath "${libPath.msedge}" \ 107 - opt/microsoft/${shortName}/msedge 108 - 109 - patchelf \ 110 - --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ 111 - opt/microsoft/${shortName}/msedge-sandbox 112 - 113 - patchelf \ 114 - --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ 115 - opt/microsoft/${shortName}/msedge_crashpad_handler 116 - 117 - patchelf \ 118 - --set-rpath "${libPath.libwidevinecdm}" \ 119 - opt/microsoft/${shortName}/WidevineCdm/_platform_specific/linux_x64/libwidevinecdm.so 120 - 121 - patchelf \ 122 - --set-rpath "${libPath.libGLESv2}" \ 123 - opt/microsoft/${shortName}/libGLESv2.so 124 - 125 - patchelf \ 126 - --set-rpath "${libPath.liboneauth}" \ 127 - opt/microsoft/${shortName}/liboneauth.so 128 - '' + lib.optionalString (lib.versionOlder version "121") '' 129 - patchelf \ 130 - --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ 131 - --set-rpath "${libPath.naclHelper}" \ 132 - opt/microsoft/${shortName}/nacl_helper 133 - ''; 134 - 135 - installPhase = '' 136 - mkdir -p $out 137 - cp -R opt usr/bin usr/share $out 138 - 139 - ${if channel == "stable" 140 - then "ln -sf $out/bin/${longName} $out/bin/${baseName}-${channel}" 141 - else "ln -sf $out/opt/microsoft/${shortName}/${baseName}-${channel} $out/opt/microsoft/${shortName}/${baseName}"} 142 - 143 - ln -sf $out/opt/microsoft/${shortName}/${longName} $out/bin/${longName} 144 - 145 - rm -rf $out/share/doc 146 - rm -rf $out/opt/microsoft/${shortName}/cron 147 - 148 - for icon in '16' '24' '32' '48' '64' '128' '256' 149 - do 150 - ${ "icon_source=$out/opt/microsoft/${shortName}/product_logo_\${icon}${iconSuffix}.png" } 151 - ${ "icon_target=$out/share/icons/hicolor/\${icon}x\${icon}/apps" } 152 - mkdir -p $icon_target 153 - cp $icon_source $icon_target/microsoft-edge${desktopSuffix}.png 154 - done 155 - 156 - substituteInPlace $out/share/applications/${longName}.desktop \ 157 - --replace /usr/bin/${baseName}-${channel} $out/bin/${longName} 158 - 159 - substituteInPlace $out/share/gnome-control-center/default-apps/${longName}.xml \ 160 - --replace /opt/microsoft/${shortName} $out/opt/microsoft/${shortName} 161 - 162 - substituteInPlace $out/share/menu/${longName}.menu \ 163 - --replace /opt/microsoft/${shortName} $out/opt/microsoft/${shortName} 164 - 165 - substituteInPlace $out/opt/microsoft/${shortName}/xdg-mime \ 166 - --replace "\''${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" "\''${XDG_DATA_DIRS:-/run/current-system/sw/share}" \ 167 - --replace "xdg_system_dirs=/usr/local/share/:/usr/share/" "xdg_system_dirs=/run/current-system/sw/share/" \ 168 - --replace /usr/bin/file ${file}/bin/file 169 - 170 - substituteInPlace $out/opt/microsoft/${shortName}/default-app-block \ 171 - --replace /opt/microsoft/${shortName} $out/opt/microsoft/${shortName} 172 - 173 - substituteInPlace $out/opt/microsoft/${shortName}/xdg-settings \ 174 - --replace "\''${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" "\''${XDG_DATA_DIRS:-/run/current-system/sw/share}" \ 175 - --replace "\''${XDG_CONFIG_DIRS:-/etc/xdg}" "\''${XDG_CONFIG_DIRS:-/run/current-system/sw/etc/xdg}" 176 - ''; 177 - 178 - postFixup = '' 179 - wrapProgram "$out/bin/${longName}" \ 180 - --prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.pname}-${gtk3.version}" \ 181 - --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \ 182 - --add-flags ${lib.escapeShellArg commandLineArgs} 183 - ''; 184 - 185 - # We only want automatic updates for stable, beta and dev will get updated by the same script 186 - # and are only used for testing. 187 - passthru = lib.optionalAttrs (channel == "stable") { updateScript = ./update.py; }; 188 - 189 - meta = with lib; { 190 - homepage = "https://www.microsoft.com/en-us/edge"; 191 - description = "Web browser from Microsoft"; 192 - license = licenses.unfree; 193 - sourceProvenance = with sourceTypes; [ binaryNativeCode ]; 194 - platforms = [ "x86_64-linux" ]; 195 - maintainers = with maintainers; [ zanculmarktum kuwii rhysmdnz ]; 196 - }; 197 - }
-20
pkgs/applications/networking/browsers/microsoft-edge/default.nix
··· 1 - { 2 - beta = import ./browser.nix { 3 - channel = "beta"; 4 - version = "130.0.2849.5"; 5 - revision = "1"; 6 - hash = "sha256-chvB84+zu6/xgRHyUk33aicc44QJLxxdOOu0ngqmsFM="; 7 - }; 8 - dev = import ./browser.nix { 9 - channel = "dev"; 10 - version = "130.0.2849.1"; 11 - revision = "1"; 12 - hash = "sha256-JObqtaaUR6J4rZ90WWw7Ku5Ntl/QBWHo23T7Ohu5p1s="; 13 - }; 14 - stable = import ./browser.nix { 15 - channel = "stable"; 16 - version = "129.0.2792.65"; 17 - revision = "1"; 18 - hash = "sha256-xuCtHptE2CG4aiY7gu2sWW3Km4qfB0E/L/PBACIaKOc="; 19 - }; 20 - }
-70
pkgs/applications/networking/browsers/microsoft-edge/update.py
··· 1 - #! /usr/bin/env nix-shell 2 - #! nix-shell -i python3 -p python3Packages.packaging python3Packages.debian 3 - 4 - import base64 5 - import textwrap 6 - from urllib import request 7 - 8 - from collections import OrderedDict 9 - from debian.deb822 import Packages 10 - from debian.debian_support import Version 11 - from os.path import abspath, dirname 12 - 13 - PIN_PATH = dirname(abspath(__file__)) + '/default.nix' 14 - 15 - def packages(): 16 - packages_url = 'https://packages.microsoft.com/repos/edge/dists/stable/main/binary-amd64/Packages' 17 - handle = request.urlopen(packages_url) 18 - return handle 19 - 20 - 21 - def latest_packages(packages: bytes): 22 - latest_packages: OrderedDict[str, Packages] = {} 23 - for package in Packages.iter_paragraphs(packages, use_apt_pkg=False): 24 - name: str = package['Package'] 25 - if not name.startswith('microsoft-edge-'): 26 - continue 27 - channel = name.replace('microsoft-edge-', '') 28 - if channel not in latest_packages: 29 - latest_packages[channel] = package 30 - else: 31 - old_package = latest_packages[channel] 32 - if old_package.get_version() < package.get_version(): # type: ignore 33 - latest_packages[channel] = package 34 - return OrderedDict(sorted(latest_packages.items(), key=lambda x:x[0])) 35 - 36 - 37 - def nix_expressions(latest: dict[str, Packages]): 38 - channel_strs: list[str] = [] 39 - for channel, package in latest.items(): 40 - print(f"Processing {channel} {package['Version']}") 41 - match = Version.re_valid_version.match(package['Version']) 42 - assert match is not None 43 - 44 - version = match.group('upstream_version') 45 - revision = match.group('debian_revision') 46 - sri = 'sha256-' + \ 47 - base64.b64encode(bytes.fromhex(package['SHA256'])).decode('ascii') 48 - 49 - channel_str = textwrap.dedent( 50 - f'''\ 51 - {channel} = import ./browser.nix {{ 52 - channel = "{channel}"; 53 - version = "{version}"; 54 - revision = "{revision}"; 55 - hash = "{sri}"; 56 - }};''' 57 - ) 58 - channel_strs.append(channel_str) 59 - return channel_strs 60 - 61 - 62 - def write_expression(): 63 - latest = latest_packages(packages()) 64 - channel_strs = nix_expressions(latest) 65 - nix_expr = '{\n' + textwrap.indent('\n'.join(channel_strs), ' ') + '\n}\n' 66 - with open(PIN_PATH, 'w') as f: 67 - f.write(nix_expr) 68 - 69 - 70 - write_expression()
+287
pkgs/by-name/mi/microsoft-edge/package.nix
··· 1 + { 2 + fetchurl, 3 + lib, 4 + makeWrapper, 5 + patchelf, 6 + stdenv, 7 + 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 48 + 49 + # Command line programs 50 + coreutils, 51 + 52 + # command line arguments which are always set e.g "--disable-gpu" 53 + commandLineArgs ? "", 54 + 55 + # Will crash without. 56 + systemd, 57 + 58 + # Loaded at runtime. 59 + libexif, 60 + pciutils, 61 + 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, 80 + 81 + # Necessary for USB audio devices. 82 + libpulseaudio, 83 + pulseSupport ? true, 84 + 85 + adwaita-icon-theme, 86 + gsettings-desktop-schemas, 87 + 88 + # For video acceleration via VA-API (--enable-features=VaapiVideoDecoder) 89 + libva, 90 + libvaSupport ? true, 91 + 92 + # For Vulkan support (--enable-features=Vulkan) 93 + addDriverRunpath, 94 + 95 + # Edge Specific 96 + libuuid, 97 + }: 98 + 99 + let 100 + 101 + opusWithCustomModes = libopus.override { withCustomModes = true; }; 102 + 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 + ]; 167 + in 168 + 169 + stdenv.mkDerivation (finalAttrs: { 170 + pname = "microsoft-edge"; 171 + version = "130.0.2849.46"; 172 + 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-QschcHSDoYakjf4oYXIc40SyniCufNmjHJPuvRazdSw="; 176 + }; 177 + 178 + # With strictDeps on, some shebangs were not being patched correctly 179 + # ie, $out/share/microsoft/msedge/microsoft-edge 180 + strictDeps = false; 181 + 182 + nativeBuildInputs = [ 183 + makeWrapper 184 + patchelf 185 + ]; 186 + 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 + ]; 196 + 197 + unpackPhase = '' 198 + runHook preUnpack 199 + ar x $src 200 + tar xf data.tar.xz 201 + runHook postUnpack 202 + ''; 203 + 204 + rpath = lib.makeLibraryPath deps + ":" + lib.makeSearchPathOutput "lib" "lib64" deps; 205 + binpath = lib.makeBinPath deps; 206 + 207 + installPhase = '' 208 + runHook preInstall 209 + 210 + appname=msedge 211 + dist=stable 212 + 213 + exe=$out/bin/microsoft-edge 214 + 215 + mkdir -p $out/bin $out/share 216 + cp -v -a opt/* $out/share 217 + cp -v -a usr/share/* $out/share 218 + 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" 222 + 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 232 + 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 245 + 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}}" \ 254 + --add-flags "--simulate-outdated-no-au='Tue, 31 Dec 2099 23:59:59 GMT'" \ 255 + --add-flags ${lib.escapeShellArg commandLineArgs} 256 + 257 + # Make sure that libGL and libvulkan are found by ANGLE libGLESv2.so 258 + patchelf --set-rpath $rpath $out/share/microsoft/$appname/lib*GL* 259 + 260 + # Edge specific set liboneauth 261 + patchelf --set-rpath $rpath $out/share/microsoft/$appname/liboneauth.so 262 + 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 267 + 268 + runHook postInstall 269 + ''; 270 + 271 + passthru.updateScript = ./update.py; 272 + 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 + }; 287 + })
+44
pkgs/by-name/mi/microsoft-edge/update.py
··· 1 + #! /usr/bin/env nix-shell 2 + #! nix-shell -i python3 -p python3Packages.packaging python3Packages.debian common-updater-scripts 3 + 4 + import base64 5 + import textwrap 6 + import os 7 + from urllib import request 8 + 9 + from collections import OrderedDict 10 + from debian.deb822 import Packages 11 + from debian.debian_support import Version 12 + from os.path import abspath, dirname 13 + 14 + PIN_PATH = dirname(abspath(__file__)) + '/default.nix' 15 + 16 + def packages(): 17 + packages_url = 'https://packages.microsoft.com/repos/edge/dists/stable/main/binary-amd64/Packages' 18 + handle = request.urlopen(packages_url) 19 + return handle 20 + 21 + 22 + def latest_packages(packages: bytes): 23 + latest_packages: OrderedDict[str, Packages] = {} 24 + for package in Packages.iter_paragraphs(packages, use_apt_pkg=False): 25 + name: str = package['Package'] 26 + if not name.startswith('microsoft-edge-stable'): 27 + continue 28 + channel = name.replace('microsoft-edge-', '') 29 + if channel not in latest_packages: 30 + latest_packages[channel] = package 31 + else: 32 + old_package = latest_packages[channel] 33 + if old_package.get_version() < package.get_version(): # type: ignore 34 + latest_packages[channel] = package 35 + return OrderedDict(sorted(latest_packages.items(), key=lambda x:x[0])) 36 + 37 + 38 + def write_expression(): 39 + latest = latest_packages(packages()) 40 + version = Version.re_valid_version.match(latest['stable']['Version']).group('upstream_version') 41 + os.system(f'update-source-version microsoft-edge "{version}"') 42 + 43 + 44 + write_expression()
-4
pkgs/top-level/all-packages.nix
··· 21910 21910 21911 21911 microsoft-gsl = callPackage ../development/libraries/microsoft-gsl { }; 21912 21912 21913 - microsoft-edge = callPackage (import ../applications/networking/browsers/microsoft-edge).stable { }; 21914 - microsoft-edge-beta = callPackage (import ../applications/networking/browsers/microsoft-edge).beta { }; 21915 - microsoft-edge-dev = callPackage (import ../applications/networking/browsers/microsoft-edge).dev { }; 21916 - 21917 21913 micronucleus = callPackage ../development/tools/misc/micronucleus { }; 21918 21914 21919 21915 markdown-anki-decks = callPackage ../tools/misc/markdown-anki-decks { };