From f3a2296445df5ca6b8aa6aac6132365c0735c751 Mon Sep 17 00:00:00 2001 From: Paul Haerle Date: Tue, 4 Jul 2023 09:14:55 +0200 Subject: [PATCH] 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> --- pkgs/tools/security/passage/darwin-getopt-path.patch | 12 ++++++++++++ pkgs/tools/security/passage/default.nix | 9 +++++++++ 2 files changed, 21 insertions(+) create mode 100644 pkgs/tools/security/passage/darwin-getopt-path.patch diff --git a/pkgs/tools/security/passage/darwin-getopt-path.patch b/pkgs/tools/security/passage/darwin-getopt-path.patch new file mode 100644 index 000000000000..1fe1efde1ac1 --- /dev/null +++ b/pkgs/tools/security/passage/darwin-getopt-path.patch @@ -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" diff --git a/pkgs/tools/security/passage/default.nix b/pkgs/tools/security/passage/default.nix index e232a3ac68d6..57e01fe39c54 100644 --- a/pkgs/tools/security/passage/default.nix +++ b/pkgs/tools/security/passage/default.nix @@ -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 ];