|
3 | 3 | buildNpmPackage, |
4 | 4 | fetchFromGitHub, |
5 | 5 | gitUpdater, |
6 | | - nodejs_20, |
7 | | - python3, |
| 6 | + nodejs, |
| 7 | + cmake, |
| 8 | + pkg-config, |
| 9 | + openssl, |
| 10 | + libdatachannel, |
| 11 | + plog, |
8 | 12 | }: |
9 | 13 |
|
| 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 | + |
10 | 69 | buildNpmPackage rec { |
11 | 70 | pname = "webtorrent-mpv-hook"; |
12 | | - version = "1.4.1"; |
| 71 | + version = "1.4.4"; |
13 | 72 |
|
14 | 73 | src = fetchFromGitHub { |
15 | 74 | owner = "mrxdst"; |
16 | 75 | repo = pname; |
17 | 76 | rev = "v${version}"; |
18 | | - hash = "sha256-/dMtXcIyfAs++Zgz2CxRW0tkzn5QjS+WVGChlCyrU0U="; |
| 77 | + hash = "sha256-qFeQBVPZZFKkxz1fhK3+ah3TPDovklhhQwtv09TiSqo="; |
19 | 78 | }; |
20 | 79 | passthru.updateScript = gitUpdater { rev-prefix = "v"; }; |
21 | 80 |
|
22 | 81 | 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}'" |
24 | 83 | # This executable is just for telling non-Nix users how to install |
25 | 84 | substituteInPlace package.json --replace-fail '"bin": "build/bin.mjs",' "" |
26 | 85 | rm -rf src/bin.ts |
27 | 86 | ''; |
28 | 87 |
|
29 | | - npmDepsHash = "sha256-EqHPBoYyBuW9elxQH/XVTZoPkKHC6+7aksYo60t7WA4="; |
| 88 | + npmDepsHash = "sha256-fKzXdbtxC2+63/GZdvPOxvBpQ5rzgvfseigOgpP1n5I="; |
30 | 89 | makeCacheWritable = true; |
| 90 | + npmFlags = [ "--ignore-scripts" ]; |
31 | 91 |
|
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 | + ''; |
36 | 96 | postInstall = '' |
37 | 97 | mkdir -p $out/share/mpv/scripts/ |
38 | 98 | ln -s $out/lib/node_modules/webtorrent-mpv-hook/build/webtorrent.js $out/share/mpv/scripts/ |
|
0 commit comments