nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 runCommand,
3 makeWrapper,
4 fontconfig_file,
5 chromium,
6 fetchzip,
7 revision,
8 suffix,
9 system,
10 throwSystem,
11 lib,
12 alsa-lib,
13 at-spi2-atk,
14 atk,
15 autoPatchelfHook,
16 cairo,
17 cups,
18 dbus,
19 expat,
20 glib,
21 gobject-introspection,
22 libGL,
23 libgbm,
24 libgcc,
25 libxkbcommon,
26 nspr,
27 nss,
28 pango,
29 patchelf,
30 pciutils,
31 stdenv,
32 systemd,
33 vulkan-loader,
34 libxrandr,
35 libxfixes,
36 libxext,
37 libxdamage,
38 libxcomposite,
39 libx11,
40 libxcb,
41 ...
42}:
43let
44 # Playwright expects different directory names for different architectures:
45 # - linux-x64 expects: chrome-linux64
46 # - linux-arm64 expects: chrome-linux
47 chromeDir =
48 {
49 x86_64-linux = "chrome-linux64";
50 aarch64-linux = "chrome-linux";
51 }
52 .${system} or throwSystem;
53
54 chromium-linux = stdenv.mkDerivation {
55 name = "playwright-chromium";
56 src = fetchzip {
57 url = "https://playwright.azureedge.net/builds/chromium/${revision}/chromium-${suffix}.zip";
58 hash =
59 {
60 x86_64-linux = "sha256-r715GrQMPRIsM2/Z6SRyvo/6j4fbWXKfCCh//Cc2DGw=";
61 aarch64-linux = "sha256-bS8CstCia8dm2DG9vBKHjsfeoXkyBZStBefu0kD8c2o=";
62 }
63 .${system} or throwSystem;
64 };
65
66 nativeBuildInputs = [
67 autoPatchelfHook
68 patchelf
69 makeWrapper
70 ];
71 buildInputs = [
72 alsa-lib
73 at-spi2-atk
74 atk
75 cairo
76 cups
77 dbus
78 expat
79 glib
80 gobject-introspection
81 libgbm
82 libgcc
83 libxkbcommon
84 nspr
85 nss
86 pango
87 stdenv.cc.cc.lib
88 systemd
89 libx11
90 libxcomposite
91 libxdamage
92 libxext
93 libxfixes
94 libxrandr
95 libxcb
96 ];
97
98 installPhase = ''
99 runHook preInstall
100
101 mkdir -p $out/${chromeDir}
102 cp -R . $out/${chromeDir}
103
104 wrapProgram $out/${chromeDir}/chrome \
105 --set-default SSL_CERT_FILE /etc/ssl/certs/ca-bundle.crt \
106 --set-default FONTCONFIG_FILE ${fontconfig_file}
107
108 runHook postInstall
109 '';
110
111 appendRunpaths = lib.makeLibraryPath [
112 libGL
113 vulkan-loader
114 pciutils
115 ];
116
117 postFixup = ''
118 # replace bundled vulkan-loader since we are also already adding our own to RPATH
119 rm "$out/${chromeDir}/libvulkan.so.1"
120 ln -s -t "$out/${chromeDir}" "${lib.getLib vulkan-loader}/lib/libvulkan.so.1"
121 '';
122 };
123 chromium-darwin = fetchzip {
124 url = "https://playwright.azureedge.net/builds/chromium/${revision}/chromium-${suffix}.zip";
125 stripRoot = false;
126 hash =
127 {
128 x86_64-darwin = "sha256-kGHlIxS9Ti362XmBt+aepYV45cCZoBRqJ+YBsLasDp0=";
129 aarch64-darwin = "sha256-LwY25Ckh1ZY+L196shf8ydF4IHXUIeI83Yqp8KG+nc4=";
130 }
131 .${system} or throwSystem;
132 };
133in
134{
135 x86_64-linux = chromium-linux;
136 aarch64-linux = chromium-linux;
137 x86_64-darwin = chromium-darwin;
138 aarch64-darwin = chromium-darwin;
139}
140.${system} or throwSystem