nixpkgs/pkgs/tools/system/which/default.nix
Sergei Trofimovich a25d6143c6 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.
2023-09-05 09:26:41 +01:00

29 lines
808 B
Nix

{ lib, stdenv, fetchurl }:
stdenv.mkDerivation rec {
pname = "which";
version = "2.21";
src = fetchurl {
url = "mirror://gnu/which/which-${version}.tar.gz";
sha256 = "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl";
};
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";
platforms = platforms.all;
license = licenses.gpl3;
};
}