passage: use getopt from nix on darwin (#241293)

* passage: use getopt from nix on darwin

This removes an ugly hack from upstream which hard-codes a bunch of
paths to find gnu-getopt (as opposed to darwins getopt in
/usr/bin/getopt).

This lets nix-built passage fail on systems which don't have one of
those already installed (i.e. from homebrew).

As upstream seemingly doesn't provide a way to override this easily yet,
we do it ourselves.

---------

Co-authored-by: Weijia Wang <9713184+wegank@users.noreply.github.com>
This commit is contained in:
Paul Haerle 2023-07-04 09:14:55 +02:00 committed by GitHub
parent 75769df6f1
commit f3a2296445
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View file

@ -0,0 +1,12 @@
diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
index 9a1fda8..4f7ce3d 100644
--- a/src/platform/darwin.sh
+++ b/src/platform/darwin.sh
@@ -39,6 +39,6 @@ qrcode() {
fi
}
-GETOPT="$({ test -x /usr/local/opt/gnu-getopt/bin/getopt && echo /usr/local/opt/gnu-getopt; } || brew --prefix gnu-getopt 2>/dev/null || { command -v port &>/dev/null && echo /opt/local; } || echo /usr/local)/bin/getopt"
+GETOPT="@GETOPT@"
SHRED="srm -f -z"
BASE64="openssl base64"

View file

@ -2,8 +2,10 @@
, stdenv
, fetchFromGitHub
, makeBinaryWrapper
, substituteAll
, bash
, age
, getopt
, git ? null
, xclip ? null
# Used to pretty-print list of all stored passwords, but is not needed to fetch
@ -22,6 +24,13 @@ stdenv.mkDerivation {
sha256 = "1val8wl9kzlxj4i1rrh2iiyf97w9akffvr0idvbkdb09hfzz4lz8";
};
patches = [
(substituteAll {
src = ./darwin-getopt-path.patch;
GETOPT = "${getopt}/bin/getopt";
})
];
nativeBuildInputs = [ makeBinaryWrapper ];
extraPath = lib.makeBinPath [ age git xclip tree ];