ff2mpv-go: use 'PATH' to invoke 'mpv'

Patching in the full-path to the binary is more robust, unfortunately
this means that a user of `ff2mpv-go` can't use their own wrapped `mpv`
without overriding the package.

As a practical example: using home-manager to configure `mpv` with
additional scripts will *not* work with the package as it was previously
written.

With this commit, we now rely on `PATH` lookups to find the `mpv`
binary, this should prioritize a user's customized `mpv`.
This commit is contained in:
Bruno BELANYI 2023-12-25 17:53:08 +01:00
parent f36a80e54d
commit c1272a1529

View file

@ -1,6 +1,7 @@
{ lib { lib
, buildGoModule , buildGoModule
, fetchgit , fetchgit
, makeWrapper
, mpv , mpv
}: }:
buildGoModule rec { buildGoModule rec {
@ -13,17 +14,21 @@ buildGoModule rec {
hash = "sha256-e/AuOA3isFTyBf97Zwtr16yo49UdYzvktV5PKB/eH/s="; hash = "sha256-e/AuOA3isFTyBf97Zwtr16yo49UdYzvktV5PKB/eH/s=";
}; };
vendorHash = null; nativeBuildInputs = [
makeWrapper
];
postPatch = '' vendorHash = null;
substituteInPlace ff2mpv.go --replace '"mpv"' '"${lib.getExe mpv}"'
'';
postInstall = '' postInstall = ''
mkdir -p "$out/lib/mozilla/native-messaging-hosts" mkdir -p "$out/lib/mozilla/native-messaging-hosts"
$out/bin/ff2mpv-go --manifest > "$out/lib/mozilla/native-messaging-hosts/ff2mpv.json" $out/bin/ff2mpv-go --manifest > "$out/lib/mozilla/native-messaging-hosts/ff2mpv.json"
''; '';
postFixup = ''
wrapProgram $out/bin/ff2mpv-go --suffix PATH ":" ${lib.makeBinPath [ mpv ]}
'';
meta = with lib; { meta = with lib; {
description = "Native messaging host for ff2mpv written in Go"; description = "Native messaging host for ff2mpv written in Go";
homepage = "https://git.clsr.net/util/ff2mpv-go/"; homepage = "https://git.clsr.net/util/ff2mpv-go/";