1{
2 lib,
3 stdenv,
4 fetchurl,
5 file,
6 zlib,
7 libgnurx,
8 updateAutotoolsGnuConfigScriptsHook,
9 testers,
10}:
11
12# Note: this package is used for bootstrapping fetchurl, and thus
13# cannot use fetchpatch! All mutable patches (generated by GitHub or
14# cgit) that are needed here should be included directly in Nixpkgs as
15# files.
16
17stdenv.mkDerivation (finalAttrs: {
18 pname = "file";
19 version = "5.45";
20
21 src = fetchurl {
22 urls = [
23 "https://astron.com/pub/file/file-${finalAttrs.version}.tar.gz"
24 "https://distfiles.macports.org/file/file-${finalAttrs.version}.tar.gz"
25 ];
26 hash = "sha256-/Jf1ECm7DiyfTjv/79r2ePDgOe6HK53lwAKm0Jx4TYI=";
27 };
28
29 outputs = [
30 "out"
31 "dev"
32 "man"
33 ];
34
35 patches = [
36 # Upstream patch to fix 32-bit tests.
37 #
38 # It is included in 5.46+, but we are not updating to it or a later version until:
39 #
40 # https://bugs.astron.com/view.php?id=622
41 # https://bugs.astron.com/view.php?id=638
42 #
43 # are resolved. See also description of the 1st bug here:
44 #
45 # https://github.com/NixOS/nixpkgs/pull/402318#issuecomment-2881163359
46 ./32-bit-time_t.patch
47 ];
48
49 strictDeps = true;
50 enableParallelBuilding = true;
51
52 nativeBuildInputs = [
53 updateAutotoolsGnuConfigScriptsHook
54 ]
55 ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) file;
56 buildInputs = [ zlib ] ++ lib.optional stdenv.hostPlatform.isMinGW libgnurx;
57
58 # https://bugs.astron.com/view.php?id=382
59 doCheck = !stdenv.buildPlatform.isMusl;
60
61 makeFlags = lib.optional stdenv.hostPlatform.isWindows "FILE_COMPILE=file";
62
63 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
64
65 meta = with lib; {
66 homepage = "https://darwinsys.com/file";
67 description = "Program that shows the type of files";
68 maintainers = with maintainers; [ doronbehar ];
69 license = licenses.bsd2;
70 pkgConfigModules = [ "libmagic" ];
71 platforms = platforms.all;
72 mainProgram = "file";
73 };
74})