From c1272a1529977a72f25d167e049a437077cfc508 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 25 Dec 2023 17:53:08 +0100 Subject: [PATCH] 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`. --- pkgs/by-name/ff/ff2mpv-go/package.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/ff/ff2mpv-go/package.nix b/pkgs/by-name/ff/ff2mpv-go/package.nix index 71e0f98a478d..7fa747b8839d 100644 --- a/pkgs/by-name/ff/ff2mpv-go/package.nix +++ b/pkgs/by-name/ff/ff2mpv-go/package.nix @@ -1,6 +1,7 @@ { lib , buildGoModule , fetchgit +, makeWrapper , mpv }: buildGoModule rec { @@ -13,17 +14,21 @@ buildGoModule rec { hash = "sha256-e/AuOA3isFTyBf97Zwtr16yo49UdYzvktV5PKB/eH/s="; }; - vendorHash = null; + nativeBuildInputs = [ + makeWrapper + ]; - postPatch = '' - substituteInPlace ff2mpv.go --replace '"mpv"' '"${lib.getExe mpv}"' - ''; + vendorHash = null; postInstall = '' mkdir -p "$out/lib/mozilla/native-messaging-hosts" $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; { description = "Native messaging host for ff2mpv written in Go"; homepage = "https://git.clsr.net/util/ff2mpv-go/";