about summary refs log tree commit diff
path: root/pkgs/by-name/ff/ff2mpv-rust/package.nix
blob: a0d78cb2c3bc0b505730ccca0babfbd32cdb71fb (plain) (blame)
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
{ lib
, rustPlatform
, fetchFromGitHub
}:

let
  firefoxPaths = [
    "lib/mozilla/native-messaging-hosts"

    # wrapFirefox only links lib/mozilla path, so this is ineffective
    # Still the above path works, despite documentation stating otherwise
    # See: https://librewolf.net/docs/faq/#how-do-i-get-native-messaging-to-work
    # "lib/librewolf/native-messaging-hosts"
  ];

  chromiumPaths = [
    "etc/chromium/native-messaging-hosts"
    "etc/opt/vivaldi/native-messaging-hosts"
    "etc/opt/chrome/native-messaging-hosts"
    "etc/opt/edge/native-messaging-hosts"
  ];
in

rustPlatform.buildRustPackage rec {
  pname = "ff2mpv-rust";
  version = "1.1.4";

  src = fetchFromGitHub {
    owner = "ryze312";
    repo = "ff2mpv-rust";
    rev = version;
    hash = "sha256-lQ1VRz/1HYZ3Il/LNNL+Jr6zFvGyxw9rUuzCCA1DZYo=";
  };

  cargoHash = "sha256-cbueToB7zDHV4k9K8RusHjnMR0ElXsPEfuqHYli25nc=";

  postInstall = ''
    $out/bin/ff2mpv-rust manifest > manifest.json
    $out/bin/ff2mpv-rust manifest_chromium > manifest_chromium.json

    for path in ${toString firefoxPaths}
    do
        mkdir -p "$out/$path"
        cp manifest.json "$out/$path/ff2mpv.json"
    done

    for path in ${toString chromiumPaths}
    do
        mkdir -p "$out/$path"
        cp manifest_chromium.json "$out/$path/ff2mpv.json"
    done
  '';

  meta = with lib; {
    description = "Native messaging host for ff2mpv written in Rust";
    homepage = "https://github.com/ryze312/ff2mpv-rust";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ arthsmn ryze ];
    mainProgram = "ff2mpv-rust";
  };
}