1 # How to generate a new version:
3 # Update version and hash as usual.
6 # git clone https://github.com/hensm/fx_cast.git
8 # # Add `"name": "fx_cast_bridge", "version": "...",` to package.json and package-lock.json
9 # nix run nixpkgs#nodePackages.node2nix -- -c node2nix -l package-lock.json -d
10 # cp -v node-*.nix package*.json ${nixpkgs_path:?}/pkgs/tools/misc/fx_cast/
13 nodeEnv = import ./node-env.nix {
14 inherit (pkgs) nodejs stdenv lib python2 runCommand writeTextFile writeShellScript;
16 libtool = if stdenv.isDarwin then pkgs.darwin.cctools else null;
18 nodePackages = import ./node-packages.nix {
19 inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
21 globalBuildInputs = [pkgs.avahi-compat];
24 stdenv.mkDerivation rec {
25 pname = "fx_cast_bridge";
28 src = pkgs.fetchFromGitHub {
32 hash = "sha256-hB4NVJW2exHoKsMp0CKzHerYgj8aR77rV+ZsCoWA1Dg=";
35 buildInputs = with pkgs; [
40 ln -vs ${nodePackages.nodeDependencies}/lib/node_modules app/node_modules
41 # The temporary home solves the "failed with exit code 243"
42 HOME="$(mktemp -d)" npm run build:app
46 mkdir -p $out/bin $out/lib/mozilla/native-messaging-hosts $out/opt
48 substituteInPlace dist/app/fx_cast_bridge.json \
49 --replace "$(realpath dist/app/fx_cast_bridge.sh)" "$out/bin/fx_cast_bridge"
50 mv dist/app/fx_cast_bridge.json $out/lib/mozilla/native-messaging-hosts
53 NODE_PATH=${nodePackages.nodeDependencies}/lib/node_modules exec ${pkgs.nodejs}/bin/node $out/opt/fx_cast_bridge/src/main.js --_name fx_cast_bridge \"\$@\"
54 " >$out/bin/fx_cast_bridge
55 chmod +x $out/bin/fx_cast_bridge
57 mv dist/app $out/opt/fx_cast_bridge
60 meta = with pkgs.lib; {
61 description = "Implementation of the Chrome Sender API (Chromecast) within Firefox";
62 homepage = "https://hensm.github.io/fx_cast/";
63 license = licenses.mit;
64 maintainers = with maintainers; [ dtzWill kevincox ];