-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirefox-playwright.nix
64 lines (52 loc) · 1.66 KB
/
firefox-playwright.nix
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
{ pkgs ? import <nixpkgs> { }, rev }:
let
inherit (pkgs) fetchzip;
inherit (pkgs.stdenv) mkDerivation;
inherit (pkgs.stdenv.hostPlatform) system;
selectSystem = attrs:
attrs.${system} or (throw "Unsupported system: ${system}");
suffix = selectSystem {
# Not sure how other system compatibility is, needs trial & error
x86_64-linux = "ubuntu-20.04";
# aarch64-linux = "ubuntu-20.04-arm64";
# x86_64-darwin = "mac";
# aarch64-darwin = "mac-arm64";
};
sha256 = {
"1350" = selectSystem {
x86_64-linux = "sha256-4RcGVaY4WQ/rPX+yRf4TrRYXpCnYfh1CUL6onNmvaIg=";
};
}.${rev};
upstream_firefox = fetchzip {
url =
"https://playwright.azureedge.net/builds/firefox/${rev}/firefox-${suffix}.zip";
inherit sha256;
stripRoot = true;
};
in
mkDerivation {
name = "firefox-playwright";
version = rev;
src = upstream_firefox;
nativeBuildInputs = [ pkgs.patchelf ];
installPhase = ''
mkdir $out
cp -r $src/* $out/
# patchelf the binary
wrapper="${pkgs.firefox-bin}/bin/firefox"
binary="$(readlink -f $(<"$wrapper" grep '^exec ' | grep -o -P '/nix/store/[^"]+' | head -n 1))"
interpreter="$(patchelf --print-interpreter "$binary")"
rpath="$(patchelf --print-rpath "$binary")"
find $out -executable -type f | while read i; do
chmod u+w "$i"
[[ $i == *.so ]] || patchelf --set-interpreter "$interpreter" "$i"
patchelf --set-rpath "$rpath" "$i"
chmod u-w "$i"
done
# create the wrapper script
rm $out/firefox
<"$wrapper" grep -vE '^exec ' > $out/firefox
echo "exec \"$out/firefox-bin\" \"\$@\"" >> $out/firefox
chmod a+x $out/firefox
'';
}