Skip to content

Commit 6b645ff

Browse files
mpvScripts.webtorrent-mpv-hook: 1.4.1 -> 1.4.4 (#350461)
Co-authored-by: nicoo <[email protected]>
1 parent 22baf87 commit 6b645ff

File tree

1 file changed

+70
-10
lines changed

1 file changed

+70
-10
lines changed

pkgs/applications/video/mpv/scripts/webtorrent-mpv-hook.nix

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,96 @@
33
buildNpmPackage,
44
fetchFromGitHub,
55
gitUpdater,
6-
nodejs_20,
7-
python3,
6+
nodejs,
7+
cmake,
8+
pkg-config,
9+
openssl,
10+
libdatachannel,
11+
plog,
812
}:
913

14+
let
15+
# Modified from pkgs/by-name/ht/httptoolkit-server/package.nix
16+
nodeDatachannel = buildNpmPackage {
17+
pname = "node-datachannel";
18+
version = "0.10.1";
19+
20+
src = fetchFromGitHub {
21+
owner = "murat-dogan";
22+
repo = "node-datachannel";
23+
rev = "refs/tags/v${nodeDatachannel.version}";
24+
hash = "sha256-r5tBg645ikIWm+RU7Muw/JYyd7AMpkImD0Xygtm1MUk=";
25+
};
26+
27+
npmFlags = [ "--ignore-scripts" ];
28+
29+
makeCacheWritable = true;
30+
31+
npmDepsHash = "sha256-1ZJd0Y45B3CT2YPXDYfCuFMBo5uggWRuDH11eCobyyY=";
32+
33+
nativeBuildInputs = [
34+
cmake
35+
pkg-config
36+
];
37+
38+
buildInputs = [
39+
openssl
40+
libdatachannel
41+
plog
42+
];
43+
44+
dontUseCmakeConfigure = true;
45+
46+
env.NIX_CFLAGS_COMPILE = "-I${nodejs}/include/node";
47+
48+
preBuild = ''
49+
# don't use static libs and don't use FetchContent
50+
substituteInPlace CMakeLists.txt \
51+
--replace-fail 'OPENSSL_USE_STATIC_LIBS TRUE' 'OPENSSL_USE_STATIC_LIBS FALSE' \
52+
--replace-fail 'if(NOT libdatachannel)' 'if(false)' \
53+
--replace-fail 'datachannel-static' 'datachannel'
54+
sed -i '2ifind_package(plog)' CMakeLists.txt
55+
56+
# don't fetch node headers
57+
substituteInPlace node_modules/cmake-js/lib/dist.js \
58+
--replace-fail '!this.downloaded' 'false'
59+
'';
60+
61+
installPhase = ''
62+
runHook preInstall
63+
install -Dm755 build/Release/*.node -t $out/build/Release
64+
runHook postInstall
65+
'';
66+
};
67+
in
68+
1069
buildNpmPackage rec {
1170
pname = "webtorrent-mpv-hook";
12-
version = "1.4.1";
71+
version = "1.4.4";
1372

1473
src = fetchFromGitHub {
1574
owner = "mrxdst";
1675
repo = pname;
1776
rev = "v${version}";
18-
hash = "sha256-/dMtXcIyfAs++Zgz2CxRW0tkzn5QjS+WVGChlCyrU0U=";
77+
hash = "sha256-qFeQBVPZZFKkxz1fhK3+ah3TPDovklhhQwtv09TiSqo=";
1978
};
2079
passthru.updateScript = gitUpdater { rev-prefix = "v"; };
2180

2281
postPatch = ''
23-
substituteInPlace src/webtorrent.ts --replace-fail "node_path: 'node'" "node_path: '${lib.getExe nodejs_20}'"
82+
substituteInPlace src/webtorrent.ts --replace-fail "node_path: 'node'" "node_path: '${lib.getExe nodejs}'"
2483
# This executable is just for telling non-Nix users how to install
2584
substituteInPlace package.json --replace-fail '"bin": "build/bin.mjs",' ""
2685
rm -rf src/bin.ts
2786
'';
2887

29-
npmDepsHash = "sha256-EqHPBoYyBuW9elxQH/XVTZoPkKHC6+7aksYo60t7WA4=";
88+
npmDepsHash = "sha256-fKzXdbtxC2+63/GZdvPOxvBpQ5rzgvfseigOgpP1n5I=";
3089
makeCacheWritable = true;
90+
npmFlags = [ "--ignore-scripts" ];
3191

32-
nativeBuildInputs = [
33-
python3 # Fixes node-gyp on aarch64-linux
34-
];
35-
92+
postConfigure = ''
93+
# manually place our prebuilt `node-datachannel` binary into its place, since we used '--ignore-scripts'
94+
ln -s ${nodeDatachannel}/build node_modules/node-datachannel/build
95+
'';
3696
postInstall = ''
3797
mkdir -p $out/share/mpv/scripts/
3898
ln -s $out/lib/node_modules/webtorrent-mpv-hook/build/webtorrent.js $out/share/mpv/scripts/

0 commit comments

Comments
 (0)