nixpkgs/pkgs/by-name/fx/fx-cast-bridge/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

59 lines
1.6 KiB
Nix

{ lib, buildNpmPackage, fetchFromGitHub, avahi-compat, nodejs_18, python3 }:
buildNpmPackage rec {
pname = "fx-cast-bridge";
version = "0.3.1";
nodejs = nodejs_18;
src = fetchFromGitHub {
owner = "hensm";
repo = "fx_cast";
rev = "v${version}";
hash = "sha256-hB4NVJW2exHoKsMp0CKzHerYgj8aR77rV+ZsCoWA1Dg=";
};
sourceRoot = "${src.name}/app";
npmDepsHash = "sha256-GLrDRZqKcX1PDGREx+MLZ1TEjr88r9nz4TvZ9nvo40g=";
nativeBuildInputs = [ python3 ];
buildInputs = [ avahi-compat ];
postPatch = ''
substituteInPlace bin/lib/paths.js \
--replace "../../../" "../../"
'';
dontNpmInstall = true;
installPhase = ''
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=\"$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
runHook postInstall
'';
meta = with lib; {
description = "Implementation of the Chrome Sender API (Chromecast) within Firefox";
homepage = "https://hensm.github.io/fx_cast/";
license = licenses.mit;
maintainers = [ ];
mainProgram = "fx_cast_bridge";
};
}