Skip to content

Instantly share code, notes, and snippets.

@phryneas
Last active April 1, 2022 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phryneas/f1887366bd355d8c658498e2afa5bb62 to your computer and use it in GitHub Desktop.
Save phryneas/f1887366bd355d8c658498e2afa5bb62 to your computer and use it in GitHub Desktop.
Replay.io on NixOS
{
"replay": {
"url": "https://static.replay.io/downloads/linux-gecko-20220331-59d0a686993f-ffd8d6280276.tar.bz2",
"sha256": "0pf1ihxkx8dr1hn8v84sb8pgyg4xwpvjlk6jlp5bkpzp5zhyskqy"
},
"recordreplay-lib": {
"url": "https://static.replay.io/downloads/linux-recordreplay-ffd8d6280276.tgz",
"sha256": "1sif40b7zk5mxibqpncdv00yxp7kh6jl37jq12ggm36nswwr9l7g"
}
}
#!/usr/bin/env sh
# e.g. linux-gecko-20220331-59d0a686993f-ffd8d6280276
BUILD_ID=$( #
curl https://static.replay.io/downloads/linux-replay.tar.bz2 -o - \
| tar xj replay/libxul.so --to-stdout \
| strings \
| grep linux-gecko
)
REVISION=$(echo $BUILD_ID | sed 's/^.*-//')
REPLAY_DL=https://static.replay.io/downloads/${BUILD_ID}.tar.bz2
LIB_DL=https://static.replay.io/downloads/linux-recordreplay-${REVISION}.tgz
REPLAY_HASH=$(nix-prefetch-url --unpack --type sha256 "${REPLAY_DL}")
LIB_HASH=$(nix-prefetch-url --type sha256 "${LIB_DL}")
cat >replay-hashes.json <<EOF
{
"replay": {
"url": "${REPLAY_DL}",
"sha256": "${REPLAY_HASH}"
},
"recordreplay-lib": {
"url": "${LIB_DL}",
"sha256": "${LIB_HASH}"
}
}
EOF
{stdenv, lib, fetchurl, autoPatchelfHook, makeWrapper, libcxx, libX11, libXt, libXdamage, glib, gtk3, dbus-glib, openssl }:
let
pinned = lib.importJSON ./replay-hashes.json;
recordreplay = fetchurl pinned.recordreplay-lib;
in
stdenv.mkDerivation rec {
name = "replay.io";
version = "master";
binaryName = "replay";
src = fetchTarball pinned.replay;
buildInputs = [
autoPatchelfHook
makeWrapper
dbus-glib
glib
gtk3
libX11
libXdamage
libXt
libcxx
openssl
];
postUnpack = ''
cp ${recordreplay} source/linux-recordreplay.so
'';
patchPhase = ''
patchelf --set-interpreter ${stdenv.cc.bintools.dynamicLinker} ${binaryName}
'';
installPhase = ''
mkdir -p $out
cp -r * $out
mkdir $out/bin
makeWrapper $out/replay \
$out/bin/replay-io \
--set "RECORD_REPLAY_DRIVER" "$out/linux-recordreplay.so"
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment