From a25d6143c6517218a470298cf826737ef623fab3 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Tue, 5 Sep 2023 09:24:28 +0100 Subject: [PATCH] which: enable 64-bit API on 32-bit systems Without the change `which` fails to find programs on filesystems with 64-bit inodes when `which` itself is 32-bit. In my case it is `btrfs` and `i686-linux`. `bison` is in the PATH: $ dev>bison bison: missing operand Try 'bison --help' for more information. But `which` fails to find it: $ which bison which: no bison in ... `bison` is a file with an inode number that overflows 2^31 limit: $ stat ~/bin/bison File: ~/bin/bison Size: 674260 Blocks: 1320 IO Block: 4096 regular file Device: 0,29 Inode: 4384368825 Links: 2 Access: (0555/-r-xr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2023-09-05 04:48:43.000000000 +0100 Modify: 1970-01-01 01:00:01.000000000 +0100 Change: 2023-09-05 04:48:43.821566578 +0100 Birth: 2023-09-05 04:48:43.772565733 +0100 The change fixes `which` run. --- pkgs/tools/system/which/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/tools/system/which/default.nix b/pkgs/tools/system/which/default.nix index aecf68e8c7fa..82316541f4c7 100644 --- a/pkgs/tools/system/which/default.nix +++ b/pkgs/tools/system/which/default.nix @@ -12,6 +12,13 @@ stdenv.mkDerivation rec { strictDeps = true; enableParallelBuilding = true; + env.NIX_CFLAGS_COMPILE = toString ( + # Enable 64-bit file API. Otherwise `which` fails to find tools + # on filesystems with 64-bit inodes (like `btrfs`) when running + # binaries from 32-bit systems (like `i686-linux`). + lib.optional stdenv.hostPlatform.is32bit "-D_FILE_OFFSET_BITS=64" + ); + meta = with lib; { homepage = "https://www.gnu.org/software/which/"; description = "Shows the full path of (shell) commands";