Unverified Commit 857df777 authored by Robert Schütz's avatar Robert Schütz Committed by GitHub
Browse files

Merge pull request #245562 from PedroHLC/fx_cast_bridge/buildNpmPackage

fx_cast_bridge: adopt buildNpmPackage; rename to fx-cast-bridge
parents 66ce081f 1a357a92
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
, gnome/*.gnome-shell*/
, browserpass, gnome-browser-connector, uget-integrator, plasma5Packages, bukubrow, pipewire
, tridactyl-native
, fx_cast_bridge
, fx-cast-bridge
, udev
, libkrb5
, libva
@@ -69,7 +69,7 @@ let
          ++ lib.optional (cfg.enableGnomeExtensions or false) gnome-browser-connector
          ++ lib.optional (cfg.enableUgetIntegrator or false) uget-integrator
          ++ lib.optional (cfg.enablePlasmaBrowserIntegration or false) plasma5Packages.plasma-browser-integration
          ++ lib.optional (cfg.enableFXCastBridge or false) fx_cast_bridge
          ++ lib.optional (cfg.enableFXCastBridge or false) fx-cast-bridge
          ++ extraNativeMessagingHosts
        ;
      libs =   lib.optionals stdenv.isLinux [ udev libva mesa libnotify xorg.libXScrnSaver cups pciutils ]
+55 −0
Original line number Diff line number Diff line
# How to generate a new version:
#
# Update version and hash as usual.
#
# ```
# git clone https://github.com/hensm/fx_cast.git
# cd fx_cast/app
# # Add `"name": "fx_cast_bridge", "version": "...",` to package.json and package-lock.json
# nix run nixpkgs#nodePackages.node2nix -- -c node2nix -l package-lock.json -d
# cp -v node-*.nix package*.json ${nixpkgs_path:?}/pkgs/tools/misc/fx_cast/
# ```
{ pkgs, stdenv }: let
  nodeEnv = import ./node-env.nix {
    inherit (pkgs) nodejs stdenv lib python2 runCommand writeTextFile writeShellScript;
    inherit pkgs;
    libtool = if stdenv.isDarwin then pkgs.darwin.cctools else null;
  };
  nodePackages = import ./node-packages.nix {
    inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
    inherit nodeEnv;
    globalBuildInputs = [pkgs.avahi-compat];
  };
in
stdenv.mkDerivation rec {
  pname = "fx_cast_bridge";
{ lib, buildNpmPackage, fetchFromGitHub, avahi-compat, nodejs, python3 }:

buildNpmPackage rec {
  pname = "fx-cast-bridge";
  version = "0.3.1";

  src = pkgs.fetchFromGitHub {
  src = fetchFromGitHub {
    owner = "hensm";
    repo = "fx_cast";
    rev = "v${version}";
    hash = "sha256-hB4NVJW2exHoKsMp0CKzHerYgj8aR77rV+ZsCoWA1Dg=";
  };
  sourceRoot = "source/app";
  npmDepsHash = "sha256-GLrDRZqKcX1PDGREx+MLZ1TEjr88r9nz4TvZ9nvo40g=";

  buildInputs = with pkgs; [
    nodejs
  ];
  nativeBuildInputs = [ python3 ];
  buildInputs = [ avahi-compat ];

  buildPhase = ''
    ln -vs ${nodePackages.nodeDependencies}/lib/node_modules app/node_modules
    # The temporary home solves the "failed with exit code 243"
    HOME="$(mktemp -d)" npm run build:app
  postPatch = ''
    substituteInPlace bin/lib/paths.js \
      --replace "../../../" "../../"
  '';

  dontNpmInstall = true;
  installPhase = ''
    mkdir -p $out/bin $out/lib/mozilla/native-messaging-hosts $out/opt
    runHook preInstall

    mkdir -p $out/{bin,lib/mozilla/native-messaging-hosts}

    substituteInPlace dist/app/fx_cast_bridge.json \
      --replace "$(realpath dist/app/fx_cast_bridge.sh)" "$out/bin/fx_cast_bridge"
    mv dist/app/fx_cast_bridge.json $out/lib/mozilla/native-messaging-hosts

    rm dist/app/fx_cast_bridge.sh
    mv dist/app $out/lib/fx_cast_bridge
    mv node_modules $out/lib/fx_cast_bridge/node_modules

    echo "#! /bin/sh
      NODE_PATH=${nodePackages.nodeDependencies}/lib/node_modules exec ${pkgs.nodejs}/bin/node $out/opt/fx_cast_bridge/src/main.js --_name fx_cast_bridge \"\$@\"
    NODE_PATH=\"$out/lib/node_modules\" \\
      exec ${nodejs}/bin/node \\
      $out/lib/fx_cast_bridge/src/main.js \\
      --_name fx_cast_bridge \"\$@\"
    " >$out/bin/fx_cast_bridge
    chmod +x $out/bin/fx_cast_bridge

    mv dist/app $out/opt/fx_cast_bridge
    runHook postInstall
  '';

  meta = with pkgs.lib; {
  meta = with lib; {
    description = "Implementation of the Chrome Sender API (Chromecast) within Firefox";
    homepage = "https://hensm.github.io/fx_cast/";
    license = licenses.mit;
    maintainers = with maintainers; [ dtzWill kevincox ];
    maintainers = with maintainers; [ dtzWill pedrohlc ];
  };
}
+0 −686

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −2043

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −3950

File deleted.

Preview size limit exceeded, changes collapsed.

Loading