1{
2 lib,
3 rustPlatform,
4 fetchFromGitHub,
5}:
6
7let
8 firefoxPaths = [
9 "lib/mozilla/native-messaging-hosts"
10
11 # wrapFirefox only links lib/mozilla path, so this is ineffective
12 # Still the above path works, despite documentation stating otherwise
13 # See: https://librewolf.net/docs/faq/#how-do-i-get-native-messaging-to-work
14 # "lib/librewolf/native-messaging-hosts"
15 ];
16
17 chromiumPaths = [
18 "etc/chromium/native-messaging-hosts"
19 "etc/opt/vivaldi/native-messaging-hosts"
20 "etc/opt/chrome/native-messaging-hosts"
21 "etc/opt/edge/native-messaging-hosts"
22 ];
23in
24
25rustPlatform.buildRustPackage rec {
26 pname = "ff2mpv-rust";
27 version = "1.1.7";
28
29 src = fetchFromGitHub {
30 owner = "ryze312";
31 repo = "ff2mpv-rust";
32 rev = version;
33 hash = "sha256-kJpKcwwwGjFYE7R4ZhkEGK44QqxsUEB/Scj0RoySta4=";
34 };
35
36 cargoHash = "sha256-O8OAynSdZdtqNS+wAQ1oAs2HjueC41O8RFqESRHr+6o=";
37
38 postInstall = ''
39 $out/bin/ff2mpv-rust manifest > manifest.json
40 $out/bin/ff2mpv-rust manifest_chromium > manifest_chromium.json
41
42 for path in ${toString firefoxPaths}
43 do
44 mkdir -p "$out/$path"
45 cp manifest.json "$out/$path/ff2mpv.json"
46 done
47
48 for path in ${toString chromiumPaths}
49 do
50 mkdir -p "$out/$path"
51 cp manifest_chromium.json "$out/$path/ff2mpv.json"
52 done
53 '';
54
55 meta = with lib; {
56 description = "Native messaging host for ff2mpv written in Rust";
57 homepage = "https://github.com/ryze312/ff2mpv-rust";
58 license = licenses.gpl3Only;
59 maintainers = with maintainers; [ ryze ];
60 mainProgram = "ff2mpv-rust";
61 };
62}